Index: src/org/eclipse/tm/internal/terminal/model/TerminalTextData.java
===================================================================
RCS file: /cvsroot/dsdp/org.eclipse.tm.core/terminal/org.eclipse.tm.terminal/src/org/eclipse/tm/internal/terminal/model/TerminalTextData.java,v
retrieving revision 1.6
diff -u -r1.6 TerminalTextData.java
--- src/org/eclipse/tm/internal/terminal/model/TerminalTextData.java	11 Apr 2008 17:37:13 -0000	1.6
+++ src/org/eclipse/tm/internal/terminal/model/TerminalTextData.java	2 Jun 2010 22:07:50 -0000
@@ -222,8 +222,10 @@
 
 	public void copy(ITerminalTextData source) {
 		fData.copy(source);
+		sendLinesChangedToSnapshot(0, getHeight());
 		fCursorLine=source.getCursorLine();
 		fCursorColumn=source.getCursorColumn();
+		sendCursorChanged();
 	}
 
 	public void copyLine(ITerminalTextData source, int sourceLine, int destLine) {
Index: src/org/eclipse/tm/internal/terminal/model/TerminalTextDataFastScroll.java
===================================================================
RCS file: /cvsroot/dsdp/org.eclipse.tm.core/terminal/org.eclipse.tm.terminal/src/org/eclipse/tm/internal/terminal/model/TerminalTextDataFastScroll.java,v
retrieving revision 1.2
diff -u -r1.2 TerminalTextDataFastScroll.java
--- src/org/eclipse/tm/internal/terminal/model/TerminalTextDataFastScroll.java	19 Sep 2007 02:08:13 -0000	1.2
+++ src/org/eclipse/tm/internal/terminal/model/TerminalTextDataFastScroll.java	2 Jun 2010 22:07:50 -0000
@@ -90,10 +90,14 @@
 
 	public void copy(ITerminalTextData source) {
 		int n=source.getHeight();
+		int oldn = getHeight();
 		setDimensions(source.getHeight(),source.getWidth());
 		for (int i = 0; i < n; i++) {
 			fData.copyLine(source, i, getPositionOfLine(i));
 		}
+		for (int i = n; i < oldn; ++i) {
+			fData.cleanLine(getPositionOfLine(i));
+		}
 	}
 
 	public void copyLine(ITerminalTextData source, int sourceLine, int destLine) {
Index: plugin.xml
===================================================================
RCS file: /cvsroot/dsdp/org.eclipse.tm.core/terminal/org.eclipse.tm.terminal/plugin.xml,v
retrieving revision 1.13
diff -u -r1.13 plugin.xml
--- plugin.xml	15 Jul 2008 21:57:01 -0000	1.13
+++ plugin.xml	2 Jun 2010 22:07:50 -0000
@@ -18,7 +18,7 @@
       <context
             name="%terminal.context.name"
             description="%terminal.context.description"
-            id="org.eclipse.tm.terminal.TerminalContext"
+            id="com.aptana.org.eclipse.tm.terminal.TerminalContext"
             />
    </extension>
 	<extension point="org.eclipse.help.contexts">
@@ -28,12 +28,12 @@
          point="org.eclipse.ui.commands">
       <!-- Dummy commands for bindings, see below -->
       <command
-            categoryId="org.eclipse.tm.terminal.category1"
-            id="org.eclipse.tm.terminal.command1"
+            categoryId="com.aptana.org.eclipse.tm.terminal.category1"
+            id="com.aptana.org.eclipse.tm.terminal.command1"
             name="%terminal.insertion.name"/>
       <category
             description="%terminal.view.insertion.description"
-            id="org.eclipse.tm.terminal.category1"
+            id="com.aptana.org.eclipse.tm.terminal.category1"
             name="%terminal.insertion.category.name"/>
    </extension>
    <extension
@@ -46,63 +46,63 @@
       keys.
       -->
       <key
-            commandId="org.eclipse.tm.terminal.command1"
-            contextId="org.eclipse.tm.terminal.TerminalContext"
+            commandId="com.aptana.org.eclipse.tm.terminal.command1"
+            contextId="com.aptana.org.eclipse.tm.terminal.TerminalContext"
             schemeId="org.eclipse.ui.defaultAcceleratorConfiguration"
             sequence="Alt+A"/> <!-- Search -->
       <key
-            commandId="org.eclipse.tm.terminal.command1"
-            contextId="org.eclipse.tm.terminal.TerminalContext"
+            commandId="com.aptana.org.eclipse.tm.terminal.command1"
+            contextId="com.aptana.org.eclipse.tm.terminal.TerminalContext"
             schemeId="org.eclipse.ui.defaultAcceleratorConfiguration"
             sequence="Alt+E"/> <!-- Edit -->
       <key
-            commandId="org.eclipse.tm.terminal.command1"
-            contextId="org.eclipse.tm.terminal.TerminalContext"
+            commandId="com.aptana.org.eclipse.tm.terminal.command1"
+            contextId="com.aptana.org.eclipse.tm.terminal.TerminalContext"
             schemeId="org.eclipse.ui.defaultAcceleratorConfiguration"
             sequence="Alt+F"/> <!-- File -->
       <key
-            commandId="org.eclipse.tm.terminal.command1"
-            contextId="org.eclipse.tm.terminal.TerminalContext"
+            commandId="com.aptana.org.eclipse.tm.terminal.command1"
+            contextId="com.aptana.org.eclipse.tm.terminal.TerminalContext"
             schemeId="org.eclipse.ui.defaultAcceleratorConfiguration"
             sequence="Alt+G"/> 
       <key
-            commandId="org.eclipse.tm.terminal.command1"
-            contextId="org.eclipse.tm.terminal.TerminalContext"
+            commandId="com.aptana.org.eclipse.tm.terminal.command1"
+            contextId="com.aptana.org.eclipse.tm.terminal.TerminalContext"
             schemeId="org.eclipse.ui.defaultAcceleratorConfiguration"
             sequence="Alt+H"/> <!-- Help -->
       <key
-            commandId="org.eclipse.tm.terminal.command1"
-            contextId="org.eclipse.tm.terminal.TerminalContext"
+            commandId="com.aptana.org.eclipse.tm.terminal.command1"
+            contextId="com.aptana.org.eclipse.tm.terminal.TerminalContext"
             schemeId="org.eclipse.ui.defaultAcceleratorConfiguration"
             sequence="Alt+N"/> <!-- Navigate -->
       <key
-            commandId="org.eclipse.tm.terminal.command1"
-            contextId="org.eclipse.tm.terminal.TerminalContext"
+            commandId="com.aptana.org.eclipse.tm.terminal.command1"
+            contextId="com.aptana.org.eclipse.tm.terminal.TerminalContext"
             schemeId="org.eclipse.ui.defaultAcceleratorConfiguration"
             sequence="Alt+P"/> <!-- Project -->
       <key
-            commandId="org.eclipse.tm.terminal.command1"
-            contextId="org.eclipse.tm.terminal.TerminalContext"
+            commandId="com.aptana.org.eclipse.tm.terminal.command1"
+            contextId="com.aptana.org.eclipse.tm.terminal.TerminalContext"
             schemeId="org.eclipse.ui.defaultAcceleratorConfiguration"
             sequence="Alt+R"/> <!-- Run -->
       <key
-            commandId="org.eclipse.tm.terminal.command1"
-            contextId="org.eclipse.tm.terminal.TerminalContext"
+            commandId="com.aptana.org.eclipse.tm.terminal.command1"
+            contextId="com.aptana.org.eclipse.tm.terminal.TerminalContext"
             schemeId="org.eclipse.ui.defaultAcceleratorConfiguration"
             sequence="Alt+S"/> <!-- Source -->
       <key
-            commandId="org.eclipse.tm.terminal.command1"
-            contextId="org.eclipse.tm.terminal.TerminalContext"
+            commandId="com.aptana.org.eclipse.tm.terminal.command1"
+            contextId="com.aptana.org.eclipse.tm.terminal.TerminalContext"
             schemeId="org.eclipse.ui.defaultAcceleratorConfiguration"
             sequence="Alt+T"/> <!-- Refactor -->
       <key
-            commandId="org.eclipse.tm.terminal.command1"
-            contextId="org.eclipse.tm.terminal.TerminalContext"
+            commandId="com.aptana.org.eclipse.tm.terminal.command1"
+            contextId="com.aptana.org.eclipse.tm.terminal.TerminalContext"
             schemeId="org.eclipse.ui.defaultAcceleratorConfiguration"
             sequence="Alt+V"/> <!-- CVS -->
       <key
-            commandId="org.eclipse.tm.terminal.command1"
-            contextId="org.eclipse.tm.terminal.TerminalContext"
+            commandId="com.aptana.org.eclipse.tm.terminal.command1"
+            contextId="com.aptana.org.eclipse.tm.terminal.TerminalContext"
             schemeId="org.eclipse.ui.defaultAcceleratorConfiguration"
             sequence="Alt+W"/> <!-- Window -->
    </extension>
Index: schema/terminalConnectors.exsd
===================================================================
RCS file: /cvsroot/dsdp/org.eclipse.tm.core/terminal/org.eclipse.tm.terminal/schema/terminalConnectors.exsd,v
retrieving revision 1.4
diff -u -r1.4 terminalConnectors.exsd
--- schema/terminalConnectors.exsd	10 Jul 2009 12:47:22 -0000	1.4
+++ schema/terminalConnectors.exsd	2 Jun 2010 22:07:50 -0000
@@ -1,9 +1,9 @@
 <?xml version='1.0' encoding='UTF-8'?>
 <!-- Schema file written by PDE -->
-<schema targetNamespace="org.eclipse.tm.terminal" xmlns="http://www.w3.org/2001/XMLSchema">
+<schema targetNamespace="com.aptana.org.eclipse.tm.terminal" xmlns="http://www.w3.org/2001/XMLSchema">
 <annotation>
       <appInfo>
-         <meta.schema plugin="org.eclipse.tm.terminal" id="terminalConnectors" name="Terminal Connectors"/>
+         <meta.schema plugin="com.aptana.org.eclipse.tm.terminal" id="terminalConnectors" name="Terminal Connectors"/>
       </appInfo>
       <documentation>
          
Index: src/org/eclipse/tm/internal/terminal/provisional/api/ITerminalConnector.java
===================================================================
RCS file: /cvsroot/dsdp/org.eclipse.tm.core/terminal/org.eclipse.tm.terminal/src/org/eclipse/tm/internal/terminal/provisional/api/ITerminalConnector.java,v
retrieving revision 1.12
diff -u -r1.12 ITerminalConnector.java
--- src/org/eclipse/tm/internal/terminal/provisional/api/ITerminalConnector.java	10 Jul 2009 12:47:21 -0000	1.12
+++ src/org/eclipse/tm/internal/terminal/provisional/api/ITerminalConnector.java	2 Jun 2010 22:07:50 -0000
@@ -16,8 +16,6 @@
 import java.io.OutputStream;
 
 import org.eclipse.core.runtime.IAdaptable;
-import org.eclipse.tm.internal.terminal.control.ITerminalViewControl;
-import org.eclipse.tm.internal.terminal.provisional.api.provider.TerminalConnectorImpl;
 
 /**
  * A contributed connection type to manage a single connection.
@@ -26,14 +24,14 @@
  * <code>org.eclipse.tm.terminal.terminalConnectors</code> extension point. This
  * class gives access to the static markup of a terminal connector extension as
  * well as providing the lifecycle management for the dynamically loaded
- * {@link TerminalConnectorImpl} instance, which performs the actual
+ * {@link org.eclipse.tm.internal.terminal.provisional.api.provider.TerminalConnectorImpl} instance, which performs the actual
  * communications. This pattern allows for lazy initialization, bundle
- * activation and class loading of the actual {@link TerminalConnectorImpl}
+ * activation and class loading of the actual {@link org.eclipse.tm.internal.terminal.provisional.api.provider.TerminalConnectorImpl}
  * instance.
  *
  * Clients can get terminal connector instances from the
  * {@link TerminalConnectorExtension} class, or from
- * {@link ITerminalViewControl#getTerminalConnector()} when running inside an
+ * {@link org.eclipse.tm.internal.terminal.control.ITerminalViewControl#getTerminalConnector()} when running inside an
  * active terminal widget.
  *
  * @noimplement This interface is not intended to be implemented by clients.
@@ -69,7 +67,7 @@
 	boolean isHidden();
 
 	/**
-	 * @return true if the {@link TerminalConnectorImpl} has been initialized.
+	 * @return true if the {@link org.eclipse.tm.internal.terminal.provisional.api.provider.TerminalConnectorImpl} has been initialized.
 	 * If there was an initialization error, {@link #getInitializationErrorMessage()}
 	 * returns the error message.
 	 * @since org.eclipse.tm.terminal 2.0
Index: src/org/eclipse/tm/internal/terminal/provisional/api/TerminalConnectorExtension.java
===================================================================
RCS file: /cvsroot/dsdp/org.eclipse.tm.core/terminal/org.eclipse.tm.terminal/src/org/eclipse/tm/internal/terminal/provisional/api/TerminalConnectorExtension.java,v
retrieving revision 1.15
diff -u -r1.15 TerminalConnectorExtension.java
--- src/org/eclipse/tm/internal/terminal/provisional/api/TerminalConnectorExtension.java	10 Jul 2009 12:47:21 -0000	1.15
+++ src/org/eclipse/tm/internal/terminal/provisional/api/TerminalConnectorExtension.java	2 Jun 2010 22:07:50 -0000
@@ -66,7 +66,7 @@
 	 * @since org.eclipse.tm.terminal 2.0
 	 */
 	public static ITerminalConnector makeTerminalConnector(String id) {
-		IConfigurationElement[] config = RegistryFactory.getRegistry().getConfigurationElementsFor("org.eclipse.tm.terminal.terminalConnectors"); //$NON-NLS-1$
+		IConfigurationElement[] config = RegistryFactory.getRegistry().getConfigurationElementsFor("com.aptana.org.eclipse.tm.terminal.terminalConnectors"); //$NON-NLS-1$
 		for (int i = 0; i < config.length; i++) {
 			if(id.equals(config[i].getAttribute("id"))) { //$NON-NLS-1$
 				return makeConnector(config[i]);
@@ -87,7 +87,7 @@
 	 * @since org.eclipse.tm.terminal 2.0 return value is ITerminalConnector[]
 	 */
 	public static ITerminalConnector[] makeTerminalConnectors() {
-		IConfigurationElement[] config = RegistryFactory.getRegistry().getConfigurationElementsFor("org.eclipse.tm.terminal.terminalConnectors"); //$NON-NLS-1$
+		IConfigurationElement[] config = RegistryFactory.getRegistry().getConfigurationElementsFor("com.aptana.org.eclipse.tm.terminal.terminalConnectors"); //$NON-NLS-1$
 		List result=new ArrayList();
 		for (int i = 0; i < config.length; i++) {
 			result.add(makeConnector(config[i]));
Index: src/org/eclipse/tm/internal/terminal/control/impl/ITerminalControlForText.java
===================================================================
RCS file: /cvsroot/dsdp/org.eclipse.tm.core/terminal/org.eclipse.tm.terminal/src/org/eclipse/tm/internal/terminal/control/impl/ITerminalControlForText.java,v
retrieving revision 1.7
diff -u -r1.7 ITerminalControlForText.java
--- src/org/eclipse/tm/internal/terminal/control/impl/ITerminalControlForText.java	8 Jun 2008 03:10:21 -0000	1.7
+++ src/org/eclipse/tm/internal/terminal/control/impl/ITerminalControlForText.java	2 Jun 2010 22:07:50 -0000
@@ -27,6 +27,8 @@
 	void setState(TerminalState state);
 	void setTerminalTitle(String title);
 	
+	void setApplicationKeypad(boolean mode);
+	
 	ITerminalConnector getTerminalConnector();
 
 	OutputStream getOutputStream();
Index: src/org/eclipse/tm/internal/terminal/control/impl/TerminalPlugin.java
===================================================================
RCS file: /cvsroot/dsdp/org.eclipse.tm.core/terminal/org.eclipse.tm.terminal/src/org/eclipse/tm/internal/terminal/control/impl/TerminalPlugin.java,v
retrieving revision 1.5
diff -u -r1.5 TerminalPlugin.java
--- src/org/eclipse/tm/internal/terminal/control/impl/TerminalPlugin.java	25 Apr 2008 20:14:44 -0000	1.5
+++ src/org/eclipse/tm/internal/terminal/control/impl/TerminalPlugin.java	2 Jun 2010 22:07:50 -0000
@@ -29,7 +29,7 @@
 
 public class TerminalPlugin extends AbstractUIPlugin {
 	protected static TerminalPlugin fDefault;
-	public static final String  PLUGIN_ID  = "org.eclipse.tm.terminal"; //$NON-NLS-1$
+	public static final String  PLUGIN_ID  = "com.aptana.org.eclipse.tm.terminal"; //$NON-NLS-1$
 	public static final String  HELP_VIEW  = PLUGIN_ID + ".terminal_view"; //$NON-NLS-1$
 
 	/**
Index: src/org/eclipse/tm/internal/terminal/textcanvas/GridCanvas.java
===================================================================
RCS file: /cvsroot/dsdp/org.eclipse.tm.core/terminal/org.eclipse.tm.terminal/src/org/eclipse/tm/internal/terminal/textcanvas/GridCanvas.java,v
retrieving revision 1.6
diff -u -r1.6 GridCanvas.java
--- src/org/eclipse/tm/internal/terminal/textcanvas/GridCanvas.java	20 May 2010 01:53:16 -0000	1.6
+++ src/org/eclipse/tm/internal/terminal/textcanvas/GridCanvas.java	2 Jun 2010 22:07:50 -0000
@@ -36,7 +36,7 @@
 		addListener(SWT.MouseWheel, new Listener() {
 			public void handleEvent(Event event) {
 				if(getVerticalBar().isVisible()) {
-					int delta=-fCellHeight;
+					int delta=-fCellHeight*5;
 					if(event.count<0)
 						delta=-delta;
 					scrollYDelta(delta);
Index: src/org/eclipse/tm/internal/terminal/textcanvas/StyleMap.java
===================================================================
RCS file: /cvsroot/dsdp/org.eclipse.tm.core/terminal/org.eclipse.tm.terminal/src/org/eclipse/tm/internal/terminal/textcanvas/StyleMap.java,v
retrieving revision 1.14
diff -u -r1.14 StyleMap.java
--- src/org/eclipse/tm/internal/terminal/textcanvas/StyleMap.java	18 Feb 2009 18:11:09 -0000	1.14
+++ src/org/eclipse/tm/internal/terminal/textcanvas/StyleMap.java	2 Jun 2010 22:07:50 -0000
@@ -29,16 +29,16 @@
 import org.eclipse.tm.terminal.model.StyleColor;
 
 public class StyleMap {
-	private static final String BLACK = "black"; //$NON-NLS-1$
-	private static final String WHITE = "white"; //$NON-NLS-1$
-	private static final String WHITE_FOREGROUND = "white_foreground"; //$NON-NLS-1$
-	private static final String GRAY = "gray"; //$NON-NLS-1$
-	private static final String MAGENTA = "magenta"; //$NON-NLS-1$
-	private static final String CYAN = "cyan"; //$NON-NLS-1$
-	private static final String YELLOW = "yellow"; //$NON-NLS-1$
-	private static final String BLUE = "blue"; //$NON-NLS-1$
-	private static final String GREEN = "green"; //$NON-NLS-1$
-	private static final String RED = "red"; //$NON-NLS-1$
+	protected static final String BLACK = "black"; //$NON-NLS-1$
+	protected static final String WHITE = "white"; //$NON-NLS-1$
+	protected static final String WHITE_FOREGROUND = "white_foreground"; //$NON-NLS-1$
+	protected static final String GRAY = "gray"; //$NON-NLS-1$
+	protected static final String MAGENTA = "magenta"; //$NON-NLS-1$
+	protected static final String CYAN = "cyan"; //$NON-NLS-1$
+	protected static final String YELLOW = "yellow"; //$NON-NLS-1$
+	protected static final String BLUE = "blue"; //$NON-NLS-1$
+	protected static final String GREEN = "green"; //$NON-NLS-1$
+	protected static final String RED = "red"; //$NON-NLS-1$
 	
 	private static final String PREFIX = "org.eclipse.tm.internal."; //$NON-NLS-1$
 	// TODO propagate the name of the font in the FontRegistry
@@ -52,7 +52,7 @@
 	private boolean fInvertColors;
 	private boolean fProportional;
 	private final int[] fOffsets=new int[256];
-	StyleMap() {
+	protected StyleMap() {
 		initColors();
 		fDefaultStyle=Style.getStyle(StyleColor.getStyleColor(BLACK),StyleColor.getStyleColor(WHITE));
 		updateFont();
@@ -123,7 +123,7 @@
 		else
 			return getColor(fColorMapBackground,style.getBackground());
 	}
-	Color getColor(Map map,StyleColor color) {
+	protected Color getColor(Map map,StyleColor color) {
 		Color c=(Color) map.get(color);
 		if(c==null) {
 			c=Display.getCurrent().getSystemColor(SWT.COLOR_GRAY);
Index: src/org/eclipse/tm/internal/terminal/textcanvas/TextLineRenderer.java
===================================================================
RCS file: /cvsroot/dsdp/org.eclipse.tm.core/terminal/org.eclipse.tm.terminal/src/org/eclipse/tm/internal/terminal/textcanvas/TextLineRenderer.java,v
retrieving revision 1.10
diff -u -r1.10 TextLineRenderer.java
--- src/org/eclipse/tm/internal/terminal/textcanvas/TextLineRenderer.java	22 May 2010 00:07:35 -0000	1.10
+++ src/org/eclipse/tm/internal/terminal/textcanvas/TextLineRenderer.java	2 Jun 2010 22:07:50 -0000
@@ -28,7 +28,7 @@
  */
 public class TextLineRenderer implements ILinelRenderer {
 	private final ITextCanvasModel fModel;
-	StyleMap fStyleMap=new StyleMap();
+	protected StyleMap fStyleMap=new StyleMap();
 	public TextLineRenderer(TextCanvas c, ITextCanvasModel model) {
 		fModel=model;
 	}
Index: src/org/eclipse/tm/internal/terminal/control/ITerminalViewControl.java
===================================================================
RCS file: /cvsroot/dsdp/org.eclipse.tm.core/terminal/org.eclipse.tm.terminal/src/org/eclipse/tm/internal/terminal/control/ITerminalViewControl.java,v
retrieving revision 1.14
diff -u -r1.14 ITerminalViewControl.java
--- src/org/eclipse/tm/internal/terminal/control/ITerminalViewControl.java	7 Jul 2008 20:38:07 -0000	1.14
+++ src/org/eclipse/tm/internal/terminal/control/ITerminalViewControl.java	2 Jun 2010 22:07:50 -0000
@@ -18,7 +18,6 @@
 import org.eclipse.swt.graphics.Font;
 import org.eclipse.swt.widgets.Control;
 import org.eclipse.tm.internal.terminal.provisional.api.ITerminalConnector;
-import org.eclipse.tm.internal.terminal.provisional.api.ITerminalControl;
 import org.eclipse.tm.internal.terminal.provisional.api.TerminalState;
 
 /**
@@ -30,7 +29,7 @@
 	 * Set the encoding that the Terminal uses to decode byte streams into
 	 * characters.
 	 *
-	 * @see ITerminalControl#setEncoding(String)
+	 * @see org.eclipse.tm.internal.terminal.provisional.api.ITerminalControl#setEncoding(String)
 	 * @since org.eclipse.tm.terminal 2.0
 	 */
 	void setEncoding(String encoding) throws UnsupportedEncodingException;
@@ -39,7 +38,7 @@
 	 * Get the Terminal's current encoding.
 	 *
 	 * @return the current Encoding of the Terminal.
-	 * @see ITerminalControl#getEncoding()
+	 * @see org.eclipse.tm.internal.terminal.provisional.api.ITerminalControl#getEncoding()
 	 * @since org.eclipse.tm.terminal 2.0
 	 */
 	String getEncoding();
@@ -68,7 +67,7 @@
     void disposeTerminal();
     String getSettingsSummary();
     ITerminalConnector[] getConnectors();
-    void setFocus();
+    boolean setFocus();
     ITerminalConnector getTerminalConnector();
     void setConnector(ITerminalConnector connector);
     void connectTerminal();
Index: src/org/eclipse/tm/internal/terminal/emulator/VT100BackendTraceDecorator.java
===================================================================
RCS file: /cvsroot/dsdp/org.eclipse.tm.core/terminal/org.eclipse.tm.terminal/src/org/eclipse/tm/internal/terminal/emulator/VT100BackendTraceDecorator.java,v
retrieving revision 1.2
diff -u -r1.2 VT100BackendTraceDecorator.java
--- src/org/eclipse/tm/internal/terminal/emulator/VT100BackendTraceDecorator.java	19 Sep 2007 02:08:10 -0000	1.2
+++ src/org/eclipse/tm/internal/terminal/emulator/VT100BackendTraceDecorator.java	2 Jun 2010 22:07:50 -0000
@@ -141,4 +141,24 @@
 		fBackend.setStyle(style);
 	}
 
+	public void setScrollingRegion(int topLine, int bottomLine) {
+		fWriter.println("setScrollingRegion("+topLine+", "+bottomLine+")"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+		fBackend.setScrollingRegion(topLine, bottomLine);
+	}
+
+	public void setAlternativeScreenBuffer(boolean enable) {
+		fWriter.println("setAlternativeScreenBuffer("+enable+")"); //$NON-NLS-1$ //$NON-NLS-2$
+		fBackend.setAlternativeScreenBuffer(enable);
+	}
+
+	public int getScrollingRegionBottomLine() {
+		fWriter.println("getScrollingRegionBottomLine()"); //$NON-NLS-1$
+		return fBackend.getScrollingRegionBottomLine();
+	}
+
+	public int getScrollingRegionTopLine() {
+		fWriter.println("getScrollingRegionTopLine()"); //$NON-NLS-1$
+		return fBackend.getScrollingRegionTopLine();
+	}
+
 }
Index: src/org/eclipse/tm/internal/terminal/emulator/VT100EmulatorBackend.java
===================================================================
RCS file: /cvsroot/dsdp/org.eclipse.tm.core/terminal/org.eclipse.tm.terminal/src/org/eclipse/tm/internal/terminal/emulator/VT100EmulatorBackend.java,v
retrieving revision 1.3
diff -u -r1.3 VT100EmulatorBackend.java
--- src/org/eclipse/tm/internal/terminal/emulator/VT100EmulatorBackend.java	8 Oct 2007 21:12:56 -0000	1.3
+++ src/org/eclipse/tm/internal/terminal/emulator/VT100EmulatorBackend.java	2 Jun 2010 22:07:50 -0000
@@ -10,6 +10,9 @@
  *******************************************************************************/
 package org.eclipse.tm.internal.terminal.emulator;
 
+import java.util.Stack;
+
+import org.eclipse.tm.internal.terminal.model.TerminalTextDataStore;
 import org.eclipse.tm.terminal.model.ITerminalTextData;
 import org.eclipse.tm.terminal.model.Style;
 
@@ -50,6 +53,11 @@
 	private Style fStyle;
 	int fLines;
 	int fColumns;
+	private int fScrollingRegionTopLine;
+	private int fScrollingRegionBottomLine;
+	private Stack fBufferStack = new Stack();
+	private boolean wrapNewLine = false;
+	
 	final private ITerminalTextData fTerminal;
 	public VT100EmulatorBackend(ITerminalTextData terminal) {
 		fTerminal=terminal;
@@ -103,6 +111,7 @@
 			}
 			fLines=lines;
 			fColumns=cols;
+			setScrollingRegion(1, fLines);
 			// make the terminal at least as high as we need lines
 			fTerminal.setDimensions(newLines, fColumns);
 			setCursor(cl, cc);
@@ -206,7 +215,7 @@
 				return;
 			assert n>0;
 			int line=toAbsoluteLine(fCursorLine);
-			int nLines=fTerminal.getHeight()-line;
+			int nLines=toAbsoluteLine(fScrollingRegionBottomLine)-line;
 			fTerminal.scroll(line, nLines, n);
 		}
 	}
@@ -236,13 +245,13 @@
 				return;
 			assert n>0;
 			int line=toAbsoluteLine(fCursorLine);
-			int nLines=fTerminal.getHeight()-line;
+			int nLines=toAbsoluteLine(fScrollingRegionBottomLine)-line;
 			fTerminal.scroll(line, nLines, -n);
 		}
 	}
+	
 	private boolean isCusorInScrollingRegion() {
-		// TODO Auto-generated method stub
-		return true;
+		return (fScrollingRegionTopLine <= fCursorLine && fCursorLine <= fScrollingRegionBottomLine);
 	}
 
 	/* (non-Javadoc)
@@ -287,18 +296,20 @@
 	public void appendString(String buffer) {
 		synchronized (fTerminal) {
 			char[] chars=buffer.toCharArray();
-			int line=toAbsoluteLine(fCursorLine);
 			int i=0;
 			while (i < chars.length) {
+				if (wrapNewLine) {
+					doNewline();
+				}
+				int line=toAbsoluteLine(fCursorLine);
 				int n=Math.min(fColumns-fCursorColumn,chars.length-i);
 				fTerminal.setChars(line, fCursorColumn, chars, i, n, fStyle);
 				int col=fCursorColumn+n;
 				i+=n;
 				// wrap needed?
 				if(col>=fColumns) {
-					doNewline();
-					line=toAbsoluteLine(fCursorLine);
 					setCursorColumn(0);
+					wrapNewLine = true;
 				} else {
 					setCursorColumn(col);
 				}
@@ -310,11 +321,14 @@
 	 * MUST be called from a synchronized block!
 	 */
 	private void doNewline() {
+		wrapNewLine = false;
 		if(fCursorLine+1>=fLines) {
 			int h=fTerminal.getHeight();
 			fTerminal.addLine();
 			if(h!=fTerminal.getHeight())
 				setCursorLine(fCursorLine+1);
+		} else if (fScrollingRegionTopLine != 0 || fScrollingRegionBottomLine != fLines-1) {
+			fTerminal.scroll(toAbsoluteLine(fScrollingRegionTopLine), fScrollingRegionBottomLine-fScrollingRegionTopLine+1, -1);
 		} else {
 			setCursorLine(fCursorLine+1);
 		}
@@ -358,6 +372,7 @@
 	 */
 	public void setCursorColumn(int targetColumn) {
 		synchronized (fTerminal) {
+			wrapNewLine = false;
 			if(targetColumn<0)
 				targetColumn=0;
 			else if(targetColumn>=fColumns)
@@ -375,6 +390,7 @@
 	 */
 	public void setCursorLine(int targetLine) {
 		synchronized (fTerminal) {
+			wrapNewLine = false;
 			if(targetLine<0)
 				targetLine=0;
 			else if(targetLine>=fLines)
@@ -404,4 +420,46 @@
 			return fColumns;
 		}
 	}
+	
+	/* (non-Javadoc)
+	 * @see org.eclipse.tm.internal.terminal.emulator.IVT100EmulatorBackend#setScrollingRegion(int, int)
+	 */
+	public void setScrollingRegion(int topLine, int bottomLine) {
+		fScrollingRegionTopLine=topLine-1;
+		fScrollingRegionBottomLine=bottomLine-1;
+	}
+
+	/* (non-Javadoc)
+	 * @see org.eclipse.tm.internal.terminal.emulator.IVT100EmulatorBackend#getScrollingRegionBottomLine()
+	 */
+	public int getScrollingRegionBottomLine() {
+		return fScrollingRegionBottomLine;
+	}
+
+	/* (non-Javadoc)
+	 * @see org.eclipse.tm.internal.terminal.emulator.IVT100EmulatorBackend#getScrollingRegionTopLine()
+	 */
+	public int getScrollingRegionTopLine() {
+		return fScrollingRegionTopLine;
+	}
+
+	/* (non-Javadoc)
+	 * @see org.eclipse.tm.internal.terminal.emulator.IVT100EmulatorBackend#setAlternativeScreenBuffer(boolean)
+	 */
+	public void setAlternativeScreenBuffer(boolean enable) {
+		synchronized (fTerminal) {
+			wrapNewLine = false;
+			if (enable) {
+				ITerminalTextData data = new TerminalTextDataStore();
+				data.copy(fTerminal);
+				fBufferStack.push(data);
+			} else if (!fBufferStack.isEmpty()) {
+				ITerminalTextData data = (ITerminalTextData) fBufferStack.pop();
+				if (fTerminal.getWidth() != data.getWidth()) {
+					data.setDimensions(data.getHeight(), fTerminal.getWidth());
+				}
+				fTerminal.copy(data);
+			}
+		}
+	}
 }
Index: src/org/eclipse/tm/internal/terminal/emulator/VT100Emulator.java
===================================================================
RCS file: /cvsroot/dsdp/org.eclipse.tm.core/terminal/org.eclipse.tm.terminal/src/org/eclipse/tm/internal/terminal/emulator/VT100Emulator.java,v
retrieving revision 1.13
diff -u -r1.13 VT100Emulator.java
--- src/org/eclipse/tm/internal/terminal/emulator/VT100Emulator.java	1 Feb 2009 12:40:23 -0000	1.13
+++ src/org/eclipse/tm/internal/terminal/emulator/VT100Emulator.java	2 Jun 2010 22:07:50 -0000
@@ -25,11 +25,11 @@
 
 import org.eclipse.swt.events.ControlEvent;
 import org.eclipse.swt.events.ControlListener;
+import org.eclipse.swt.widgets.Display;
 import org.eclipse.tm.internal.terminal.control.impl.ITerminalControlForText;
 import org.eclipse.tm.internal.terminal.control.impl.TerminalPlugin;
 import org.eclipse.tm.internal.terminal.provisional.api.ITerminalConnector;
 import org.eclipse.tm.internal.terminal.provisional.api.Logger;
-import org.eclipse.tm.internal.terminal.provisional.api.TerminalState;
 import org.eclipse.tm.terminal.model.ITerminalTextData;
 import org.eclipse.tm.terminal.model.Style;
 
@@ -115,6 +115,11 @@
 	 * in field {@link #ansiParameters}.
 	 */
 	private int nextAnsiParameter = 0;
+	
+	private int lastCursorLine = -1;
+	private int lastCursorColumn = -1;
+	
+	private boolean insertMode = false;
 
 	Reader fReader;
 
@@ -299,6 +304,10 @@
 				case '\u001b':
 					ansiState = ANSISTATE_ESCAPE; // Escape.
 					break;
+					
+				case '\u000e':
+				case '\u000f':
+					break;
 
 				default:
 					processNonControlCharacters(character);
@@ -328,6 +337,12 @@
 					ansiOsCommand.delete(0, ansiOsCommand.length());
 					break;
 
+				case '=':
+				case '>':
+					terminal.setApplicationKeypad(character == '=');
+					ansiState = ANSISTATE_INITIAL;
+					break;
+					
 				case '7':
 					// Save cursor position and character attributes
 
@@ -350,6 +365,12 @@
 					resetTerminal();
 					break;
 
+				case 'M':
+					// Reverse index
+					ansiState = ANSISTATE_INITIAL;
+					reverseIndex();
+					break;
+
 				default:
 					Logger
 							.log("Unsupported escape sequence: escape '" + character + "'"); //$NON-NLS-1$ //$NON-NLS-2$
@@ -398,6 +419,17 @@
 		text.setCursor(0, 0);
 		text.setStyle(text.getDefaultStyle());
 	}
+	
+	private void reverseIndex() {
+		int line = text.getCursorLine() - 1;
+		int topMargin = text.getScrollingRegionTopLine();
+		if (line < topMargin) {
+			text.insertLines(1);
+			line = topMargin;
+		}
+		text.setCursorLine(line);
+	}
+		
 	/**
 	 * This method is called when we have parsed an OS Command escape sequence.
 	 * The only one we support is "\e]0;...\u0007", which sets the terminal
@@ -467,6 +499,11 @@
 			processAnsiCommand_G();
 			break;
 
+		case 'h':
+			// Set Mode.
+			processAnsiCommand_h();
+			break;
+
 		case 'H':
 			// Set cursor Position.
 			processAnsiCommand_H();
@@ -482,6 +519,11 @@
 			processAnsiCommand_K();
 			break;
 
+		case 'l':
+			// Reset Mode.
+			processAnsiCommand_l();
+			break;
+
 		case 'L':
 			// Insert line(s) (current line moves down).
 			processAnsiCommand_L();
@@ -507,6 +549,11 @@
 			processAnsiCommand_P();
 			break;
 
+		case 'r':
+			// Set Top and Bottom Margins.
+			processAnsiCommand_r();
+			break;
+
 		case 'S':
 			// Scroll up.
 			// Emacs, vi, and GNU readline don't seem to use this command, so we ignore
@@ -618,8 +665,72 @@
 	 * sequence parameters (default is the upper left corner of the screen).
 	 */
 	private void processAnsiCommand_H() {
+		lastCursorLine = text.getCursorLine();
+		lastCursorColumn = text.getCursorColumn();
 		moveCursor(getAnsiParameter(0) - 1, getAnsiParameter(1) - 1);
 	}
+	
+	/**
+	 * This method sets terminal mode.
+	 */
+	private void processAnsiCommand_h() {
+		if (ansiParameters.length > 0 && ansiParameters[0].length() > 0) {
+			if (ansiParameters[0].charAt(0) == '?') {
+				ansiParameters[0].deleteCharAt(0);
+				int ansiParameter = getAnsiParameter(0);
+				switch (ansiParameter) {
+				case 1:
+					terminal.setApplicationKeypad(true);
+					break;
+				case 47:
+					text.setAlternativeScreenBuffer(true);
+					break;
+				case 1049:
+					// TODO: store position
+					text.setAlternativeScreenBuffer(true);
+					break;
+				}
+			} else {
+				int ansiParameter = getAnsiParameter(0);
+				switch (ansiParameter) {
+				case 4:
+					insertMode = true;
+					break;
+				}				
+			}
+		}
+	}
+
+	/**
+	 * This method resets terminal mode.
+	 */
+	private void processAnsiCommand_l() {
+		if (ansiParameters.length > 0 && ansiParameters[0].length() > 0) {
+			if (ansiParameters[0].charAt(0) == '?') {
+				ansiParameters[0].deleteCharAt(0);
+				int ansiParameter = getAnsiParameter(0);
+				switch (ansiParameter) {
+				case 1:
+					terminal.setApplicationKeypad(false);
+					break;
+				case 47:
+					text.setAlternativeScreenBuffer(false);
+					break;
+				case 1049:
+					// TODO: restore position
+					text.setAlternativeScreenBuffer(false);
+					break;
+				}
+			} else {
+				int ansiParameter = getAnsiParameter(0);
+				switch (ansiParameter) {
+				case 4:
+					insertMode = false;
+					break;
+				}								
+			}
+		}
+	}
 
 	/**
 	 * This method deletes some (or all) of the text on the screen without
@@ -645,7 +756,18 @@
 
 		case 2:
 			// Erase entire display.
-
+			
+			if (text.getCursorLine() == 0 && text.getCursorColumn() == 0
+					&& lastCursorLine != -1 && lastCursorColumn != -1) {
+				moveCursor(lastCursorLine, lastCursorColumn);
+				for (int i = text.getLines(); i > 0; --i) {
+					text.processNewline();
+				}
+				moveCursor(0, 0);
+				lastCursorLine = -1;
+				lastCursorColumn = -1;
+				
+			}
 			text.eraseAll();
 			break;
 
@@ -858,6 +980,13 @@
 	private void processAnsiCommand_P() {
 		text.deleteCharacters(getAnsiParameter(0));
 	}
+	
+	/**
+	 * Set Top and Bottom Margins
+	 */
+	private void processAnsiCommand_r() {
+		text.setScrollingRegion(getAnsiParameter(0), getAnsiParameter(1));
+	}
 
 	/**
 	 * This method returns one of the numeric ANSI parameters received in the
@@ -923,7 +1052,8 @@
 			character=getNextChar();
 			if(character == '\u0000' || character == '\b' || character == '\t'
 				|| character == '\u0007' || character == '\n'
-				|| character == '\r' || character == '\u001b') {
+				|| character == '\r' || character == '\u001b'
+				|| character == '\u000e' || character == '\u000f') {
 				pushBackChar(character);
 				break;
 			}
@@ -948,6 +1078,9 @@
 	 * <p>
 	 */
 	private void displayNewText(String buffer) {
+		if (insertMode) {
+			text.insertCharacters(buffer.length());
+		}
 		text.appendString(buffer);
 	}
 
@@ -956,8 +1089,11 @@
 	 * Process a BEL (Control-G) character.
 	 */
 	private void processBEL() {
-		// TODO
-		//Display.getDefault().beep();
+		Display.getDefault().asyncExec(new Runnable() {
+			public void run() {
+				Display.getCurrent().beep();
+			}
+		});
 	}
 
 	/**
@@ -1115,6 +1251,7 @@
 	public void resetState() {
 		ansiState=ANSISTATE_INITIAL;
 		text.setStyle(text.getDefaultStyle());
+		text.setCursorColumn(0);
 	}
 
 //	public OutputStream getOutputStream() {
Index: src/org/eclipse/tm/internal/terminal/emulator/IVT100EmulatorBackend.java
===================================================================
RCS file: /cvsroot/dsdp/org.eclipse.tm.core/terminal/org.eclipse.tm.terminal/src/org/eclipse/tm/internal/terminal/emulator/IVT100EmulatorBackend.java,v
retrieving revision 1.2
diff -u -r1.2 IVT100EmulatorBackend.java
--- src/org/eclipse/tm/internal/terminal/emulator/IVT100EmulatorBackend.java	19 Sep 2007 02:08:10 -0000	1.2
+++ src/org/eclipse/tm/internal/terminal/emulator/IVT100EmulatorBackend.java	2 Jun 2010 22:07:50 -0000
@@ -169,4 +169,11 @@
 
 	int getColumns();
 
+	void setScrollingRegion(int topLine, int bottomLine);
+	
+	int getScrollingRegionTopLine();
+	int getScrollingRegionBottomLine();
+	
+	void setAlternativeScreenBuffer(boolean enable);
+
 }
\ No newline at end of file
Index: src/org/eclipse/tm/internal/terminal/emulator/VT100TerminalControl.java
===================================================================
RCS file: /cvsroot/dsdp/org.eclipse.tm.core/terminal/org.eclipse.tm.terminal/src/org/eclipse/tm/internal/terminal/emulator/VT100TerminalControl.java,v
retrieving revision 1.27
diff -u -r1.27 VT100TerminalControl.java
--- src/org/eclipse/tm/internal/terminal/emulator/VT100TerminalControl.java	4 Dec 2008 19:37:11 -0000	1.27
+++ src/org/eclipse/tm/internal/terminal/emulator/VT100TerminalControl.java	2 Jun 2010 22:07:50 -0000
@@ -38,6 +38,8 @@
 import org.eclipse.core.runtime.IStatus;
 import org.eclipse.core.runtime.Status;
 import org.eclipse.core.runtime.jobs.Job;
+import org.eclipse.jface.bindings.keys.KeyStroke;
+import org.eclipse.jface.bindings.keys.SWTKeySupport;
 import org.eclipse.jface.resource.JFaceResources;
 import org.eclipse.osgi.util.NLS;
 import org.eclipse.swt.SWT;
@@ -67,6 +69,7 @@
 import org.eclipse.tm.internal.terminal.provisional.api.ITerminalControl;
 import org.eclipse.tm.internal.terminal.provisional.api.Logger;
 import org.eclipse.tm.internal.terminal.provisional.api.TerminalState;
+import org.eclipse.tm.internal.terminal.textcanvas.ILinelRenderer;
 import org.eclipse.tm.internal.terminal.textcanvas.ITextCanvasModel;
 import org.eclipse.tm.internal.terminal.textcanvas.PipedInputStream;
 import org.eclipse.tm.internal.terminal.textcanvas.PollingTextCanvasModel;
@@ -93,6 +96,14 @@
 public class VT100TerminalControl implements ITerminalControlForText, ITerminalControl, ITerminalViewControl
 {
     protected final static String[] LINE_DELIMITERS = { "\n" }; //$NON-NLS-1$
+    
+    protected final static int[] BYPASS_ACCELERATORS = new int[] {
+    	SWTKeySupport.convertKeyStrokeToAccelerator(KeyStroke.getInstance(SWT.COMMAND == SWT.MOD1 ? SWT.MOD1 : SWT.MOD1 | SWT.MOD2, 'C')),
+		SWTKeySupport.convertKeyStrokeToAccelerator(KeyStroke.getInstance(SWT.COMMAND == SWT.MOD1 ? SWT.MOD1 : SWT.MOD1 | SWT.MOD2, 'V')),
+		SWTKeySupport.convertKeyStrokeToAccelerator(KeyStroke.getInstance(SWT.COMMAND == SWT.MOD1 ? SWT.MOD1 : SWT.MOD1 | SWT.MOD2, 'A')),
+		SWTKeySupport.convertKeyStrokeToAccelerator(KeyStroke.getInstance(SWT.CONTROL, SWT.TAB)),
+		SWTKeySupport.convertKeyStrokeToAccelerator(KeyStroke.getInstance(SWT.CONTROL | SWT.SHIFT, SWT.TAB))
+    };
 
     /**
      * This field holds a reference to a TerminalText object that performs all ANSI
@@ -119,6 +130,8 @@
 
 	private volatile TerminalState fState;
 
+	private boolean isApplicationKeypad = false;
+
 	private final ITerminalTextData fTerminalModel;
 
 	/**
@@ -267,8 +280,8 @@
 	/* (non-Javadoc)
 	 * @see org.eclipse.tm.internal.terminal.provisional.api.ITerminalControl#setFocus()
 	 */
-	public void setFocus() {
-		getCtlText().setFocus();
+	public boolean setFocus() {
+		return getCtlText().setFocus();
 	}
 
 	/* (non-Javadoc)
@@ -574,11 +587,9 @@
 		// TODO how to get the initial size correctly!
 		snapshot.updateSnapshot(false);
 		ITextCanvasModel canvasModel=new PollingTextCanvasModel(snapshot);
-		fCtlText=new TextCanvas(fWndParent,canvasModel,SWT.NONE,new TextLineRenderer(fCtlText,canvasModel));
-
+		fCtlText=new TextCanvas(fWndParent,canvasModel,SWT.NONE,createLineRenderer(canvasModel));
 
 		fCtlText.setLayoutData(new GridData(GridData.FILL_BOTH));
-		fCtlText.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
 		fCtlText.addResizeHandler(new TextCanvas.ResizeListener() {
 			public void sizeChanged(int lines, int columns) {
 				fTerminalText.setDimensions(lines, columns);
@@ -591,6 +602,10 @@
 //		fViewer.setDocument(new TerminalDocument());
 		setFont(JFaceResources.getTextFont());
 	}
+	
+	protected ILinelRenderer createLineRenderer(ITextCanvasModel model) {
+		return new TextLineRenderer(null,model);
+	}
 
 	protected void setupListeners() {
 		fKeyHandler = new TerminalKeyHandler();
@@ -707,7 +722,7 @@
 			IContextService contextService = (IContextService) PlatformUI
 					.getWorkbench().getAdapter(IContextService.class);
 			contextActivation = contextService
-					.activateContext("org.eclipse.tm.terminal.TerminalContext"); //$NON-NLS-1$
+					.activateContext("com.aptana.org.eclipse.tm.terminal.TerminalContext"); //$NON-NLS-1$
 		}
 
 		public void focusLost(FocusEvent event) {
@@ -729,6 +744,19 @@
 		public void keyPressed(KeyEvent event) {
 			if (getState()==TerminalState.CONNECTING)
 				return;
+			
+			int accelerator = SWTKeySupport.convertEventToUnmodifiedAccelerator(event);
+			for (int i = 0; i < BYPASS_ACCELERATORS.length; ++i) {
+				if (BYPASS_ACCELERATORS[i] == accelerator) {
+					return;
+				}
+			}
+			char character = event.character;
+			if (character == '\u0000') {
+				if ((event.stateMask & SWT.MOD1) !=0 && event.keyCode >= SWT.F1 && event.keyCode <= SWT.F15) {
+					return;
+				}
+			}
 
 			// We set the event.doit to false to prevent any further processing of this
 			// key event.  The only reason this is here is because I was seeing the F10
@@ -738,8 +766,6 @@
 
 			event.doit = false;
 
-			char character = event.character;
-
 			//if (!isConnected()) {
 			if (fState==TerminalState.CLOSED) {
 				// Pressing ENTER while not connected causes us to connect.
@@ -773,19 +799,19 @@
 
 				switch (event.keyCode) {
 				case 0x1000001: // Up arrow.
-					sendString("\u001b[A"); //$NON-NLS-1$
+					sendString(isApplicationKeypad ? "\u001bOA" : "\u001b[A"); //$NON-NLS-1$ //$NON-NLS-2$
 					break;
 
 				case 0x1000002: // Down arrow.
-					sendString("\u001b[B"); //$NON-NLS-1$
+					sendString(isApplicationKeypad ? "\u001bOB" : "\u001b[B"); //$NON-NLS-1$ //$NON-NLS-2$
 					break;
 
 				case 0x1000003: // Left arrow.
-					sendString("\u001b[D"); //$NON-NLS-1$
+					sendString(isApplicationKeypad ? "\u001bOD" : "\u001b[D"); //$NON-NLS-1$ //$NON-NLS-2$
 					break;
 
 				case 0x1000004: // Right arrow.
-					sendString("\u001b[C"); //$NON-NLS-1$
+					sendString(isApplicationKeypad ? "\u001bOC" : "\u001b[C"); //$NON-NLS-1$ //$NON-NLS-2$
 					break;
 
 				case 0x1000005: // PgUp key.
@@ -797,11 +823,11 @@
 					break;
 
 				case 0x1000007: // Home key.
-					sendString("\u001b[H"); //$NON-NLS-1$
+					sendString(isApplicationKeypad ? "\u001bOH" : "\u001b[H"); //$NON-NLS-1$ //$NON-NLS-2$
 					break;
 
 				case 0x1000008: // End key.
-					sendString("\u001b[F"); //$NON-NLS-1$
+					sendString(isApplicationKeypad ? "\u001bOF" : "\u001b[F"); //$NON-NLS-1$ //$NON-NLS-2$
 					break;
 
 				case 0x100000a: // F1 key.
@@ -867,6 +893,17 @@
 				// It's ok to return here, because we never locally echo special keys.
 
 				return;
+			} else if (event.stateMask == 0) {
+				switch (event.keyCode) {
+				case 8:
+					sendString("\u007f"); //$NON-NLS-1$
+					return;
+				case 127:
+					sendString("\u001b[3~"); //$NON-NLS-1$
+					return;
+				default:
+					break;
+				}
 			}
 
 			// To fix SPR 110341, we consider the Alt key to be pressed only when the
@@ -1019,4 +1056,8 @@
 	public void setInvertedColors(boolean invert) {
 		fCtlText.setInvertedColors(invert);
 	}
+
+	public void setApplicationKeypad(boolean mode) {
+		isApplicationKeypad = mode;
+	}
 }
Index: META-INF/MANIFEST.MF
===================================================================
RCS file: /cvsroot/dsdp/org.eclipse.tm.core/terminal/org.eclipse.tm.terminal/META-INF/MANIFEST.MF,v
retrieving revision 1.29
diff -u -r1.29 MANIFEST.MF
--- META-INF/MANIFEST.MF	26 May 2010 09:41:46 -0000	1.29
+++ META-INF/MANIFEST.MF	2 Jun 2010 22:07:50 -0000
@@ -1,7 +1,7 @@
 Manifest-Version: 1.0
 Bundle-ManifestVersion: 2
 Bundle-Name: %pluginName
-Bundle-SymbolicName: org.eclipse.tm.terminal; singleton:=true
+Bundle-SymbolicName: com.aptana.org.eclipse.tm.terminal; singleton:=true
 Bundle-Version: 3.0.100.qualifier
 Bundle-Activator: org.eclipse.tm.internal.terminal.control.impl.TerminalPlugin
 Bundle-Vendor: %providerName
@@ -13,24 +13,10 @@
 Bundle-RequiredExecutionEnvironment: CDC-1.1/Foundation-1.1,
  J2SE-1.4
 Bundle-ClassPath: .
-Export-Package: org.eclipse.tm.internal.terminal.connector;x-friends:="org.eclipse.tm.terminal.test",
- org.eclipse.tm.internal.terminal.control;x-friends:="org.eclipse.tm.terminal.view",
- org.eclipse.tm.internal.terminal.control.actions;x-friends:="org.eclipse.tm.terminal.view",
- org.eclipse.tm.internal.terminal.control.impl;x-friends:="org.eclipse.tm.terminal.test",
- org.eclipse.tm.internal.terminal.emulator;x-friends:="org.eclipse.tm.terminal.test",
- org.eclipse.tm.internal.terminal.model;x-friends:="org.eclipse.tm.terminal.test",
- org.eclipse.tm.internal.terminal.provisional.api;
-  x-friends:="org.eclipse.tm.terminal.serial,
-   org.eclipse.tm.terminal.ssh,
-   org.eclipse.tm.terminal.telnet,
-   org.eclipse.tm.terminal.local,
-   org.eclipse.tm.terminal.view,
-   org.eclipse.tm.terminal.test",
- org.eclipse.tm.internal.terminal.provisional.api.provider;
-  x-friends:="org.eclipse.tm.terminal.serial,
-   org.eclipse.tm.terminal.ssh,
-   org.eclipse.tm.terminal.telnet,
-   org.eclipse.tm.terminal.local,
-   org.eclipse.tm.terminal.test",
- org.eclipse.tm.internal.terminal.textcanvas;x-friends:="org.eclipse.tm.terminal.test",
- org.eclipse.tm.terminal.model
+Export-Package: org.eclipse.tm.internal.terminal.control;x-friends:="com.aptana.terminal",
+ org.eclipse.tm.internal.terminal.control.actions;x-friends:="com.aptana.terminal",
+ org.eclipse.tm.internal.terminal.emulator;x-friends:="com.aptana.terminal",
+ org.eclipse.tm.internal.terminal.provisional.api;x-friends:="com.aptana.terminal",
+ org.eclipse.tm.internal.terminal.provisional.api.provider;x-friends:="com.aptana.terminal",
+ org.eclipse.tm.internal.terminal.textcanvas;x-friends:="com.aptana.terminal",
+ org.eclipse.tm.terminal.model;x-friends:="com.aptana.terminal"
Index: src/org/eclipse/tm/internal/terminal/connector/TerminalConnector.java
===================================================================
RCS file: /cvsroot/dsdp/org.eclipse.tm.core/terminal/org.eclipse.tm.terminal/src/org/eclipse/tm/internal/terminal/connector/TerminalConnector.java,v
retrieving revision 1.7
diff -u -r1.7 TerminalConnector.java
--- src/org/eclipse/tm/internal/terminal/connector/TerminalConnector.java	9 Jul 2009 10:59:44 -0000	1.7
+++ src/org/eclipse/tm/internal/terminal/connector/TerminalConnector.java	2 Jun 2010 22:07:50 -0000
@@ -23,7 +23,6 @@
 import org.eclipse.tm.internal.terminal.provisional.api.ITerminalConnector;
 import org.eclipse.tm.internal.terminal.provisional.api.ITerminalControl;
 import org.eclipse.tm.internal.terminal.provisional.api.Logger;
-import org.eclipse.tm.internal.terminal.provisional.api.TerminalConnectorExtension;
 import org.eclipse.tm.internal.terminal.provisional.api.TerminalState;
 import org.eclipse.tm.internal.terminal.provisional.api.provider.TerminalConnectorImpl;
 
@@ -44,7 +43,7 @@
  * @noextend This class is not intended to be subclassed by clients.
  * @noinstantiate This class is not intended to be instantiated by clients.
  *                Clients can get terminal connector instances through the
- *                {@link TerminalConnectorExtension} class.
+ *                {@link org.eclipse.tm.internal.terminal.provisional.api.TerminalConnectorExtension} class.
  * @since org.eclipse.tm.terminal 2.0
  */
 public class TerminalConnector implements ITerminalConnector {
Index: changes_20100507.patch
===================================================================
RCS file: changes_20100507.patch
diff -N changes_20100507.patch
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ changes_20100507.patch	1 Jan 1970 00:00:00 -0000
@@ -0,0 +1,983 @@
+Index: src/org/eclipse/tm/internal/terminal/model/TerminalTextData.java
+===================================================================
+RCS file: /cvsroot/dsdp/org.eclipse.tm.core/terminal/org.eclipse.tm.terminal/src/org/eclipse/tm/internal/terminal/model/TerminalTextData.java,v
+retrieving revision 1.6
+diff -u -r1.6 TerminalTextData.java
+--- src/org/eclipse/tm/internal/terminal/model/TerminalTextData.java	11 Apr 2008 17:37:13 -0000	1.6
++++ src/org/eclipse/tm/internal/terminal/model/TerminalTextData.java	12 May 2010 08:15:53 -0000
+@@ -222,8 +222,10 @@
+ 
+ 	public void copy(ITerminalTextData source) {
+ 		fData.copy(source);
++		sendLinesChangedToSnapshot(0, getHeight());
+ 		fCursorLine=source.getCursorLine();
+ 		fCursorColumn=source.getCursorColumn();
++		sendCursorChanged();
+ 	}
+ 
+ 	public void copyLine(ITerminalTextData source, int sourceLine, int destLine) {
+Index: src/org/eclipse/tm/internal/terminal/model/TerminalTextDataFastScroll.java
+===================================================================
+RCS file: /cvsroot/dsdp/org.eclipse.tm.core/terminal/org.eclipse.tm.terminal/src/org/eclipse/tm/internal/terminal/model/TerminalTextDataFastScroll.java,v
+retrieving revision 1.2
+diff -u -r1.2 TerminalTextDataFastScroll.java
+--- src/org/eclipse/tm/internal/terminal/model/TerminalTextDataFastScroll.java	19 Sep 2007 02:08:13 -0000	1.2
++++ src/org/eclipse/tm/internal/terminal/model/TerminalTextDataFastScroll.java	12 May 2010 08:15:53 -0000
+@@ -90,10 +90,14 @@
+ 
+ 	public void copy(ITerminalTextData source) {
+ 		int n=source.getHeight();
++		int oldn = getHeight();
+ 		setDimensions(source.getHeight(),source.getWidth());
+ 		for (int i = 0; i < n; i++) {
+ 			fData.copyLine(source, i, getPositionOfLine(i));
+ 		}
++		for (int i = n; i < oldn; ++i) {
++			fData.cleanLine(getPositionOfLine(i));
++		}
+ 	}
+ 
+ 	public void copyLine(ITerminalTextData source, int sourceLine, int destLine) {
+Index: src/org/eclipse/tm/internal/terminal/textcanvas/TextCanvas.java
+===================================================================
+RCS file: /cvsroot/dsdp/org.eclipse.tm.core/terminal/org.eclipse.tm.terminal/src/org/eclipse/tm/internal/terminal/textcanvas/TextCanvas.java,v
+retrieving revision 1.16
+diff -u -r1.16 TextCanvas.java
+--- src/org/eclipse/tm/internal/terminal/textcanvas/TextCanvas.java	8 Nov 2009 22:58:19 -0000	1.16
++++ src/org/eclipse/tm/internal/terminal/textcanvas/TextCanvas.java	12 May 2010 08:15:53 -0000
+@@ -281,6 +281,8 @@
+ 		fCellRenderer.drawLine(fCellCanvasModel, gc,line,x,y,colFirst, colLast);
+ 
+ 	}
++	protected void paintUnoccupiedSpace(GC gc, Rectangle clipping) {
++	}
+ 	protected void visibleCellRectangleChanged(int x, int y, int width, int height) {
+ 		fCellCanvasModel.setVisibleRectangle(y,x,height,width);
+ 		update();
+Index: src/org/eclipse/tm/internal/terminal/textcanvas/GridCanvas.java
+===================================================================
+RCS file: /cvsroot/dsdp/org.eclipse.tm.core/terminal/org.eclipse.tm.terminal/src/org/eclipse/tm/internal/terminal/textcanvas/GridCanvas.java,v
+retrieving revision 1.5
+diff -u -r1.5 GridCanvas.java
+--- src/org/eclipse/tm/internal/terminal/textcanvas/GridCanvas.java	4 Apr 2008 16:31:43 -0000	1.5
++++ src/org/eclipse/tm/internal/terminal/textcanvas/GridCanvas.java	12 May 2010 08:15:53 -0000
+@@ -34,7 +34,7 @@
+ 		addListener(SWT.MouseWheel, new Listener() {
+ 			public void handleEvent(Event event) {
+ 				if(getVerticalBar().isVisible()) {
+-					int delta=-fCellHeight;
++					int delta=-fCellHeight*5;
+ 					if(event.count<0)
+ 						delta=-delta;
+ 					scrollYDelta(delta);
+Index: src/org/eclipse/tm/internal/terminal/textcanvas/StyleMap.java
+===================================================================
+RCS file: /cvsroot/dsdp/org.eclipse.tm.core/terminal/org.eclipse.tm.terminal/src/org/eclipse/tm/internal/terminal/textcanvas/StyleMap.java,v
+retrieving revision 1.14
+diff -u -r1.14 StyleMap.java
+--- src/org/eclipse/tm/internal/terminal/textcanvas/StyleMap.java	18 Feb 2009 18:11:09 -0000	1.14
++++ src/org/eclipse/tm/internal/terminal/textcanvas/StyleMap.java	12 May 2010 08:15:53 -0000
+@@ -29,16 +29,16 @@
+ import org.eclipse.tm.terminal.model.StyleColor;
+ 
+ public class StyleMap {
+-	private static final String BLACK = "black"; //$NON-NLS-1$
+-	private static final String WHITE = "white"; //$NON-NLS-1$
+-	private static final String WHITE_FOREGROUND = "white_foreground"; //$NON-NLS-1$
+-	private static final String GRAY = "gray"; //$NON-NLS-1$
+-	private static final String MAGENTA = "magenta"; //$NON-NLS-1$
+-	private static final String CYAN = "cyan"; //$NON-NLS-1$
+-	private static final String YELLOW = "yellow"; //$NON-NLS-1$
+-	private static final String BLUE = "blue"; //$NON-NLS-1$
+-	private static final String GREEN = "green"; //$NON-NLS-1$
+-	private static final String RED = "red"; //$NON-NLS-1$
++	protected static final String BLACK = "black"; //$NON-NLS-1$
++	protected static final String WHITE = "white"; //$NON-NLS-1$
++	protected static final String WHITE_FOREGROUND = "white_foreground"; //$NON-NLS-1$
++	protected static final String GRAY = "gray"; //$NON-NLS-1$
++	protected static final String MAGENTA = "magenta"; //$NON-NLS-1$
++	protected static final String CYAN = "cyan"; //$NON-NLS-1$
++	protected static final String YELLOW = "yellow"; //$NON-NLS-1$
++	protected static final String BLUE = "blue"; //$NON-NLS-1$
++	protected static final String GREEN = "green"; //$NON-NLS-1$
++	protected static final String RED = "red"; //$NON-NLS-1$
+ 	
+ 	private static final String PREFIX = "org.eclipse.tm.internal."; //$NON-NLS-1$
+ 	// TODO propagate the name of the font in the FontRegistry
+@@ -52,7 +52,7 @@
+ 	private boolean fInvertColors;
+ 	private boolean fProportional;
+ 	private final int[] fOffsets=new int[256];
+-	StyleMap() {
++	protected StyleMap() {
+ 		initColors();
+ 		fDefaultStyle=Style.getStyle(StyleColor.getStyleColor(BLACK),StyleColor.getStyleColor(WHITE));
+ 		updateFont();
+@@ -123,7 +123,7 @@
+ 		else
+ 			return getColor(fColorMapBackground,style.getBackground());
+ 	}
+-	Color getColor(Map map,StyleColor color) {
++	protected Color getColor(Map map,StyleColor color) {
+ 		Color c=(Color) map.get(color);
+ 		if(c==null) {
+ 			c=Display.getCurrent().getSystemColor(SWT.COLOR_GRAY);
+Index: src/org/eclipse/tm/internal/terminal/textcanvas/VirtualCanvas.java
+===================================================================
+RCS file: /cvsroot/dsdp/org.eclipse.tm.core/terminal/org.eclipse.tm.terminal/src/org/eclipse/tm/internal/terminal/textcanvas/VirtualCanvas.java,v
+retrieving revision 1.12
+diff -u -r1.12 VirtualCanvas.java
+--- src/org/eclipse/tm/internal/terminal/textcanvas/VirtualCanvas.java	4 Apr 2008 16:31:43 -0000	1.12
++++ src/org/eclipse/tm/internal/terminal/textcanvas/VirtualCanvas.java	12 May 2010 08:15:53 -0000
+@@ -72,6 +72,9 @@
+ 		updateViewRectangle();
+ 	}
+ 	protected void scrollX(ScrollBar hBar) {
++		if (!hBar.isVisible()) {
++			return;
++		}
+ 		int hSelection = hBar.getSelection ();
+ 		int destX = -hSelection - fVirtualBounds.x;
+ 		fVirtualBounds.x = -hSelection;
+@@ -311,7 +314,7 @@
+ 		// returns false if its parent is not visible. 
+ 		if(!isVisible() || horizontal.isVisible()) {
+ 			horizontal.setPageIncrement(clientArea.width - horizontal.getIncrement());
+-			int max= fVirtualBounds.width + (size.x - clientArea.width);
++			int max= fVirtualBounds.width + (size.x - clientArea.width - getVerticalBar().getSize().x);
+ 			horizontal.setMaximum(max);
+ 			horizontal.setThumb(size.x > max ? max : size.x);
+ 		}
+@@ -326,18 +329,22 @@
+ 		}
+ 	}
+ 	protected boolean isVertialBarVisible() {
+-		return getVerticalBar().isVisible();
++		ScrollBar vertical= getVerticalBar();
++		return vertical.isVisible() && vertical.isEnabled();
+ 	}
+ 	protected void serVerticalBarVisible(boolean showVScrollBar) {
+ 		ScrollBar vertical= getVerticalBar();
++		vertical.setEnabled(showVScrollBar);
+ 		vertical.setVisible(showVScrollBar);
+ 		vertical.setSelection(0);
+ 	}
+ 	protected boolean isHorizontalBarVisble() {
+-		return getHorizontalBar().isVisible();
++		ScrollBar horizontal= getHorizontalBar();
++		return horizontal.getVisible() && horizontal.isEnabled();
+ 	}
+ 	protected void setHorizontalBarVisible(boolean showHScrollBar) {
+ 		ScrollBar horizontal= getHorizontalBar();
++		horizontal.setEnabled(showHScrollBar);
+ 		horizontal.setVisible(showHScrollBar);
+ 		horizontal.setSelection(0);
+ 	}
+Index: src/org/eclipse/tm/internal/terminal/textcanvas/TextLineRenderer.java
+===================================================================
+RCS file: /cvsroot/dsdp/org.eclipse.tm.core/terminal/org.eclipse.tm.terminal/src/org/eclipse/tm/internal/terminal/textcanvas/TextLineRenderer.java,v
+retrieving revision 1.8
+diff -u -r1.8 TextLineRenderer.java
+--- src/org/eclipse/tm/internal/terminal/textcanvas/TextLineRenderer.java	4 Apr 2008 16:31:43 -0000	1.8
++++ src/org/eclipse/tm/internal/terminal/textcanvas/TextLineRenderer.java	12 May 2010 08:15:53 -0000
+@@ -27,11 +27,9 @@
+  */
+ public class TextLineRenderer implements ILinelRenderer {
+ 	private final ITextCanvasModel fModel;
+-	StyleMap fStyleMap=new StyleMap();
+-	Color fBackgroundColor;
++	protected StyleMap fStyleMap=new StyleMap();
+ 	public TextLineRenderer(TextCanvas c, ITextCanvasModel model) {
+ 		fModel=model;
+-		fBackgroundColor=Display.getCurrent().getSystemColor(SWT.COLOR_LIST_BACKGROUND);
+ 	}
+ 	/* (non-Javadoc)
+ 	 * @see com.imagicus.thumbs.view.ICellRenderer#getCellWidth()
+@@ -47,7 +45,7 @@
+ 	}
+ 	public void drawLine(ITextCanvasModel model, GC gc, int line, int x, int y, int colFirst, int colLast) {
+ 		if(line<0 || line>=getTerminalText().getHeight() || colFirst>=getTerminalText().getWidth() || colFirst-colLast==0) {
+-			fillBackground(gc, x, y, getCellWidth()*(colFirst-colLast), getCellHeight());
++			fillBackground(gc, x, y, getCellWidth()*(colLast-colFirst), getCellHeight());
+ 		} else {
+ 			colLast=Math.min(colLast, getTerminalText().getWidth());
+ 			LineSegment[] segments=getTerminalText().getLineSegments(line, colFirst, colLast-colFirst);
+@@ -94,7 +92,7 @@
+ 	}
+ 
+ 	private Color getBackgroundColor() {
+-		return fBackgroundColor;
++		return fStyleMap.getBackgroundColor(null);
+ 	}
+ 	private void drawCursor(ITextCanvasModel model, GC gc, int row, int x, int y, int colFirst) {
+ 		if(!model.isCursorOn())
+Index: src/org/eclipse/tm/internal/terminal/provisional/api/ITerminalConnector.java
+===================================================================
+RCS file: /cvsroot/dsdp/org.eclipse.tm.core/terminal/org.eclipse.tm.terminal/src/org/eclipse/tm/internal/terminal/provisional/api/ITerminalConnector.java,v
+retrieving revision 1.12
+diff -u -r1.12 ITerminalConnector.java
+--- src/org/eclipse/tm/internal/terminal/provisional/api/ITerminalConnector.java	10 Jul 2009 12:47:21 -0000	1.12
++++ src/org/eclipse/tm/internal/terminal/provisional/api/ITerminalConnector.java	12 May 2010 08:15:53 -0000
+@@ -16,8 +16,6 @@
+ import java.io.OutputStream;
+ 
+ import org.eclipse.core.runtime.IAdaptable;
+-import org.eclipse.tm.internal.terminal.control.ITerminalViewControl;
+-import org.eclipse.tm.internal.terminal.provisional.api.provider.TerminalConnectorImpl;
+ 
+ /**
+  * A contributed connection type to manage a single connection.
+@@ -26,14 +24,14 @@
+  * <code>org.eclipse.tm.terminal.terminalConnectors</code> extension point. This
+  * class gives access to the static markup of a terminal connector extension as
+  * well as providing the lifecycle management for the dynamically loaded
+- * {@link TerminalConnectorImpl} instance, which performs the actual
++ * {@link org.eclipse.tm.internal.terminal.provisional.api.provider.TerminalConnectorImpl} instance, which performs the actual
+  * communications. This pattern allows for lazy initialization, bundle
+- * activation and class loading of the actual {@link TerminalConnectorImpl}
++ * activation and class loading of the actual {@link org.eclipse.tm.internal.terminal.provisional.api.provider.TerminalConnectorImpl}
+  * instance.
+  *
+  * Clients can get terminal connector instances from the
+  * {@link TerminalConnectorExtension} class, or from
+- * {@link ITerminalViewControl#getTerminalConnector()} when running inside an
++ * {@link org.eclipse.tm.internal.terminal.control.ITerminalViewControl#getTerminalConnector()} when running inside an
+  * active terminal widget.
+  *
+  * @noimplement This interface is not intended to be implemented by clients.
+@@ -69,7 +67,7 @@
+ 	boolean isHidden();
+ 
+ 	/**
+-	 * @return true if the {@link TerminalConnectorImpl} has been initialized.
++	 * @return true if the {@link org.eclipse.tm.internal.terminal.provisional.api.provider.TerminalConnectorImpl} has been initialized.
+ 	 * If there was an initialization error, {@link #getInitializationErrorMessage()}
+ 	 * returns the error message.
+ 	 * @since org.eclipse.tm.terminal 2.0
+Index: src/org/eclipse/tm/internal/terminal/control/impl/ITerminalControlForText.java
+===================================================================
+RCS file: /cvsroot/dsdp/org.eclipse.tm.core/terminal/org.eclipse.tm.terminal/src/org/eclipse/tm/internal/terminal/control/impl/ITerminalControlForText.java,v
+retrieving revision 1.7
+diff -u -r1.7 ITerminalControlForText.java
+--- src/org/eclipse/tm/internal/terminal/control/impl/ITerminalControlForText.java	8 Jun 2008 03:10:21 -0000	1.7
++++ src/org/eclipse/tm/internal/terminal/control/impl/ITerminalControlForText.java	12 May 2010 08:15:53 -0000
+@@ -27,6 +27,8 @@
+ 	void setState(TerminalState state);
+ 	void setTerminalTitle(String title);
+ 	
++	void setApplicationKeypad(boolean mode);
++	
+ 	ITerminalConnector getTerminalConnector();
+ 
+ 	OutputStream getOutputStream();
+Index: src/org/eclipse/tm/internal/terminal/control/ITerminalViewControl.java
+===================================================================
+RCS file: /cvsroot/dsdp/org.eclipse.tm.core/terminal/org.eclipse.tm.terminal/src/org/eclipse/tm/internal/terminal/control/ITerminalViewControl.java,v
+retrieving revision 1.14
+diff -u -r1.14 ITerminalViewControl.java
+--- src/org/eclipse/tm/internal/terminal/control/ITerminalViewControl.java	7 Jul 2008 20:38:07 -0000	1.14
++++ src/org/eclipse/tm/internal/terminal/control/ITerminalViewControl.java	12 May 2010 08:15:53 -0000
+@@ -18,7 +18,6 @@
+ import org.eclipse.swt.graphics.Font;
+ import org.eclipse.swt.widgets.Control;
+ import org.eclipse.tm.internal.terminal.provisional.api.ITerminalConnector;
+-import org.eclipse.tm.internal.terminal.provisional.api.ITerminalControl;
+ import org.eclipse.tm.internal.terminal.provisional.api.TerminalState;
+ 
+ /**
+@@ -30,7 +29,7 @@
+ 	 * Set the encoding that the Terminal uses to decode byte streams into
+ 	 * characters.
+ 	 *
+-	 * @see ITerminalControl#setEncoding(String)
++	 * @see org.eclipse.tm.internal.terminal.provisional.api.ITerminalControl#setEncoding(String)
+ 	 * @since org.eclipse.tm.terminal 2.0
+ 	 */
+ 	void setEncoding(String encoding) throws UnsupportedEncodingException;
+@@ -39,7 +38,7 @@
+ 	 * Get the Terminal's current encoding.
+ 	 *
+ 	 * @return the current Encoding of the Terminal.
+-	 * @see ITerminalControl#getEncoding()
++	 * @see org.eclipse.tm.internal.terminal.provisional.api.ITerminalControl#getEncoding()
+ 	 * @since org.eclipse.tm.terminal 2.0
+ 	 */
+ 	String getEncoding();
+Index: src/org/eclipse/tm/internal/terminal/emulator/VT100BackendTraceDecorator.java
+===================================================================
+RCS file: /cvsroot/dsdp/org.eclipse.tm.core/terminal/org.eclipse.tm.terminal/src/org/eclipse/tm/internal/terminal/emulator/VT100BackendTraceDecorator.java,v
+retrieving revision 1.2
+diff -u -r1.2 VT100BackendTraceDecorator.java
+--- src/org/eclipse/tm/internal/terminal/emulator/VT100BackendTraceDecorator.java	19 Sep 2007 02:08:10 -0000	1.2
++++ src/org/eclipse/tm/internal/terminal/emulator/VT100BackendTraceDecorator.java	12 May 2010 08:15:53 -0000
+@@ -141,4 +141,24 @@
+ 		fBackend.setStyle(style);
+ 	}
+ 
++	public void setScrollingRegion(int topLine, int bottomLine) {
++		fWriter.println("setScrollingRegion("+topLine+", "+bottomLine+")"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
++		fBackend.setScrollingRegion(topLine, bottomLine);
++	}
++
++	public void setAlternativeScreenBuffer(boolean enable) {
++		fWriter.println("setAlternativeScreenBuffer("+enable+")"); //$NON-NLS-1$ //$NON-NLS-2$
++		fBackend.setAlternativeScreenBuffer(enable);
++	}
++
++	public int getScrollingRegionBottomLine() {
++		fWriter.println("getScrollingRegionBottomLine()"); //$NON-NLS-1$
++		return fBackend.getScrollingRegionBottomLine();
++	}
++
++	public int getScrollingRegionTopLine() {
++		fWriter.println("getScrollingRegionTopLine()"); //$NON-NLS-1$
++		return fBackend.getScrollingRegionTopLine();
++	}
++
+ }
+Index: src/org/eclipse/tm/internal/terminal/emulator/VT100EmulatorBackend.java
+===================================================================
+RCS file: /cvsroot/dsdp/org.eclipse.tm.core/terminal/org.eclipse.tm.terminal/src/org/eclipse/tm/internal/terminal/emulator/VT100EmulatorBackend.java,v
+retrieving revision 1.3
+diff -u -r1.3 VT100EmulatorBackend.java
+--- src/org/eclipse/tm/internal/terminal/emulator/VT100EmulatorBackend.java	8 Oct 2007 21:12:56 -0000	1.3
++++ src/org/eclipse/tm/internal/terminal/emulator/VT100EmulatorBackend.java	12 May 2010 08:15:53 -0000
+@@ -10,6 +10,9 @@
+  *******************************************************************************/
+ package org.eclipse.tm.internal.terminal.emulator;
+ 
++import java.util.Stack;
++
++import org.eclipse.tm.internal.terminal.model.TerminalTextDataStore;
+ import org.eclipse.tm.terminal.model.ITerminalTextData;
+ import org.eclipse.tm.terminal.model.Style;
+ 
+@@ -50,6 +53,11 @@
+ 	private Style fStyle;
+ 	int fLines;
+ 	int fColumns;
++	private int fScrollingRegionTopLine;
++	private int fScrollingRegionBottomLine;
++	private Stack fBufferStack = new Stack();
++	private boolean wrapNewLine = false;
++	
+ 	final private ITerminalTextData fTerminal;
+ 	public VT100EmulatorBackend(ITerminalTextData terminal) {
+ 		fTerminal=terminal;
+@@ -103,6 +111,7 @@
+ 			}
+ 			fLines=lines;
+ 			fColumns=cols;
++			setScrollingRegion(1, fLines);
+ 			// make the terminal at least as high as we need lines
+ 			fTerminal.setDimensions(newLines, fColumns);
+ 			setCursor(cl, cc);
+@@ -206,7 +215,7 @@
+ 				return;
+ 			assert n>0;
+ 			int line=toAbsoluteLine(fCursorLine);
+-			int nLines=fTerminal.getHeight()-line;
++			int nLines=toAbsoluteLine(fScrollingRegionBottomLine)-line;
+ 			fTerminal.scroll(line, nLines, n);
+ 		}
+ 	}
+@@ -236,13 +245,13 @@
+ 				return;
+ 			assert n>0;
+ 			int line=toAbsoluteLine(fCursorLine);
+-			int nLines=fTerminal.getHeight()-line;
++			int nLines=toAbsoluteLine(fScrollingRegionBottomLine)-line;
+ 			fTerminal.scroll(line, nLines, -n);
+ 		}
+ 	}
++	
+ 	private boolean isCusorInScrollingRegion() {
+-		// TODO Auto-generated method stub
+-		return true;
++		return (fScrollingRegionTopLine <= fCursorLine && fCursorLine <= fScrollingRegionBottomLine);
+ 	}
+ 
+ 	/* (non-Javadoc)
+@@ -287,18 +296,20 @@
+ 	public void appendString(String buffer) {
+ 		synchronized (fTerminal) {
+ 			char[] chars=buffer.toCharArray();
+-			int line=toAbsoluteLine(fCursorLine);
+ 			int i=0;
+ 			while (i < chars.length) {
++				if (wrapNewLine) {
++					doNewline();
++				}
++				int line=toAbsoluteLine(fCursorLine);
+ 				int n=Math.min(fColumns-fCursorColumn,chars.length-i);
+ 				fTerminal.setChars(line, fCursorColumn, chars, i, n, fStyle);
+ 				int col=fCursorColumn+n;
+ 				i+=n;
+ 				// wrap needed?
+ 				if(col>=fColumns) {
+-					doNewline();
+-					line=toAbsoluteLine(fCursorLine);
+ 					setCursorColumn(0);
++					wrapNewLine = true;
+ 				} else {
+ 					setCursorColumn(col);
+ 				}
+@@ -310,11 +321,14 @@
+ 	 * MUST be called from a synchronized block!
+ 	 */
+ 	private void doNewline() {
++		wrapNewLine = false;
+ 		if(fCursorLine+1>=fLines) {
+ 			int h=fTerminal.getHeight();
+ 			fTerminal.addLine();
+ 			if(h!=fTerminal.getHeight())
+ 				setCursorLine(fCursorLine+1);
++		} else if (fScrollingRegionTopLine != 0 || fScrollingRegionBottomLine != fLines-1) {
++			fTerminal.scroll(toAbsoluteLine(fScrollingRegionTopLine), fScrollingRegionBottomLine-fScrollingRegionTopLine+1, -1);
+ 		} else {
+ 			setCursorLine(fCursorLine+1);
+ 		}
+@@ -358,6 +372,7 @@
+ 	 */
+ 	public void setCursorColumn(int targetColumn) {
+ 		synchronized (fTerminal) {
++			wrapNewLine = false;
+ 			if(targetColumn<0)
+ 				targetColumn=0;
+ 			else if(targetColumn>=fColumns)
+@@ -375,6 +390,7 @@
+ 	 */
+ 	public void setCursorLine(int targetLine) {
+ 		synchronized (fTerminal) {
++			wrapNewLine = false;
+ 			if(targetLine<0)
+ 				targetLine=0;
+ 			else if(targetLine>=fLines)
+@@ -404,4 +420,46 @@
+ 			return fColumns;
+ 		}
+ 	}
++	
++	/* (non-Javadoc)
++	 * @see org.eclipse.tm.internal.terminal.emulator.IVT100EmulatorBackend#setScrollingRegion(int, int)
++	 */
++	public void setScrollingRegion(int topLine, int bottomLine) {
++		fScrollingRegionTopLine=topLine-1;
++		fScrollingRegionBottomLine=bottomLine-1;
++	}
++
++	/* (non-Javadoc)
++	 * @see org.eclipse.tm.internal.terminal.emulator.IVT100EmulatorBackend#getScrollingRegionBottomLine()
++	 */
++	public int getScrollingRegionBottomLine() {
++		return fScrollingRegionBottomLine;
++	}
++
++	/* (non-Javadoc)
++	 * @see org.eclipse.tm.internal.terminal.emulator.IVT100EmulatorBackend#getScrollingRegionTopLine()
++	 */
++	public int getScrollingRegionTopLine() {
++		return fScrollingRegionTopLine;
++	}
++
++	/* (non-Javadoc)
++	 * @see org.eclipse.tm.internal.terminal.emulator.IVT100EmulatorBackend#setAlternativeScreenBuffer(boolean)
++	 */
++	public void setAlternativeScreenBuffer(boolean enable) {
++		synchronized (fTerminal) {
++			wrapNewLine = false;
++			if (enable) {
++				ITerminalTextData data = new TerminalTextDataStore();
++				data.copy(fTerminal);
++				fBufferStack.push(data);
++			} else if (!fBufferStack.isEmpty()) {
++				ITerminalTextData data = (ITerminalTextData) fBufferStack.pop();
++				if (fTerminal.getWidth() != data.getWidth()) {
++					data.setDimensions(data.getHeight(), fTerminal.getWidth());
++				}
++				fTerminal.copy(data);
++			}
++		}
++	}
+ }
+Index: src/org/eclipse/tm/internal/terminal/emulator/VT100Emulator.java
+===================================================================
+RCS file: /cvsroot/dsdp/org.eclipse.tm.core/terminal/org.eclipse.tm.terminal/src/org/eclipse/tm/internal/terminal/emulator/VT100Emulator.java,v
+retrieving revision 1.13
+diff -u -r1.13 VT100Emulator.java
+--- src/org/eclipse/tm/internal/terminal/emulator/VT100Emulator.java	1 Feb 2009 12:40:23 -0000	1.13
++++ src/org/eclipse/tm/internal/terminal/emulator/VT100Emulator.java	12 May 2010 08:15:53 -0000
+@@ -25,11 +25,11 @@
+ 
+ import org.eclipse.swt.events.ControlEvent;
+ import org.eclipse.swt.events.ControlListener;
++import org.eclipse.swt.widgets.Display;
+ import org.eclipse.tm.internal.terminal.control.impl.ITerminalControlForText;
+ import org.eclipse.tm.internal.terminal.control.impl.TerminalPlugin;
+ import org.eclipse.tm.internal.terminal.provisional.api.ITerminalConnector;
+ import org.eclipse.tm.internal.terminal.provisional.api.Logger;
+-import org.eclipse.tm.internal.terminal.provisional.api.TerminalState;
+ import org.eclipse.tm.terminal.model.ITerminalTextData;
+ import org.eclipse.tm.terminal.model.Style;
+ 
+@@ -115,6 +115,11 @@
+ 	 * in field {@link #ansiParameters}.
+ 	 */
+ 	private int nextAnsiParameter = 0;
++	
++	private int lastCursorLine = -1;
++	private int lastCursorColumn = -1;
++	
++	private boolean insertMode = false;
+ 
+ 	Reader fReader;
+ 
+@@ -299,6 +304,10 @@
+ 				case '\u001b':
+ 					ansiState = ANSISTATE_ESCAPE; // Escape.
+ 					break;
++					
++				case '\u000e':
++				case '\u000f':
++					break;
+ 
+ 				default:
+ 					processNonControlCharacters(character);
+@@ -328,6 +337,12 @@
+ 					ansiOsCommand.delete(0, ansiOsCommand.length());
+ 					break;
+ 
++				case '=':
++				case '>':
++					terminal.setApplicationKeypad(character == '=');
++					ansiState = ANSISTATE_INITIAL;
++					break;
++					
+ 				case '7':
+ 					// Save cursor position and character attributes
+ 
+@@ -350,6 +365,12 @@
+ 					resetTerminal();
+ 					break;
+ 
++				case 'M':
++					// Reverse index
++					ansiState = ANSISTATE_INITIAL;
++					reverseIndex();
++					break;
++
+ 				default:
+ 					Logger
+ 							.log("Unsupported escape sequence: escape '" + character + "'"); //$NON-NLS-1$ //$NON-NLS-2$
+@@ -398,6 +419,17 @@
+ 		text.setCursor(0, 0);
+ 		text.setStyle(text.getDefaultStyle());
+ 	}
++	
++	private void reverseIndex() {
++		int line = text.getCursorLine() - 1;
++		int topMargin = text.getScrollingRegionTopLine();
++		if (line < topMargin) {
++			text.insertLines(1);
++			line = topMargin;
++		}
++		text.setCursorLine(line);
++	}
++		
+ 	/**
+ 	 * This method is called when we have parsed an OS Command escape sequence.
+ 	 * The only one we support is "\e]0;...\u0007", which sets the terminal
+@@ -467,6 +499,11 @@
+ 			processAnsiCommand_G();
+ 			break;
+ 
++		case 'h':
++			// Set Mode.
++			processAnsiCommand_h();
++			break;
++
+ 		case 'H':
+ 			// Set cursor Position.
+ 			processAnsiCommand_H();
+@@ -482,6 +519,11 @@
+ 			processAnsiCommand_K();
+ 			break;
+ 
++		case 'l':
++			// Reset Mode.
++			processAnsiCommand_l();
++			break;
++
+ 		case 'L':
+ 			// Insert line(s) (current line moves down).
+ 			processAnsiCommand_L();
+@@ -507,6 +549,11 @@
+ 			processAnsiCommand_P();
+ 			break;
+ 
++		case 'r':
++			// Set Top and Bottom Margins.
++			processAnsiCommand_r();
++			break;
++
+ 		case 'S':
+ 			// Scroll up.
+ 			// Emacs, vi, and GNU readline don't seem to use this command, so we ignore
+@@ -618,8 +665,72 @@
+ 	 * sequence parameters (default is the upper left corner of the screen).
+ 	 */
+ 	private void processAnsiCommand_H() {
++		lastCursorLine = text.getCursorLine();
++		lastCursorColumn = text.getCursorColumn();
+ 		moveCursor(getAnsiParameter(0) - 1, getAnsiParameter(1) - 1);
+ 	}
++	
++	/**
++	 * This method sets terminal mode.
++	 */
++	private void processAnsiCommand_h() {
++		if (ansiParameters.length > 0 && ansiParameters[0].length() > 0) {
++			if (ansiParameters[0].charAt(0) == '?') {
++				ansiParameters[0].deleteCharAt(0);
++				int ansiParameter = getAnsiParameter(0);
++				switch (ansiParameter) {
++				case 1:
++					terminal.setApplicationKeypad(true);
++					break;
++				case 47:
++					text.setAlternativeScreenBuffer(true);
++					break;
++				case 1049:
++					// TODO: store position
++					text.setAlternativeScreenBuffer(true);
++					break;
++				}
++			} else {
++				int ansiParameter = getAnsiParameter(0);
++				switch (ansiParameter) {
++				case 4:
++					insertMode = true;
++					break;
++				}				
++			}
++		}
++	}
++
++	/**
++	 * This method resets terminal mode.
++	 */
++	private void processAnsiCommand_l() {
++		if (ansiParameters.length > 0 && ansiParameters[0].length() > 0) {
++			if (ansiParameters[0].charAt(0) == '?') {
++				ansiParameters[0].deleteCharAt(0);
++				int ansiParameter = getAnsiParameter(0);
++				switch (ansiParameter) {
++				case 1:
++					terminal.setApplicationKeypad(false);
++					break;
++				case 47:
++					text.setAlternativeScreenBuffer(false);
++					break;
++				case 1049:
++					// TODO: restore position
++					text.setAlternativeScreenBuffer(false);
++					break;
++				}
++			} else {
++				int ansiParameter = getAnsiParameter(0);
++				switch (ansiParameter) {
++				case 4:
++					insertMode = false;
++					break;
++				}								
++			}
++		}
++	}
+ 
+ 	/**
+ 	 * This method deletes some (or all) of the text on the screen without
+@@ -645,7 +756,18 @@
+ 
+ 		case 2:
+ 			// Erase entire display.
+-
++			
++			if (text.getCursorLine() == 0 && text.getCursorColumn() == 0
++					&& lastCursorLine != -1 && lastCursorColumn != -1) {
++				moveCursor(lastCursorLine, lastCursorColumn);
++				for (int i = text.getLines(); i > 0; --i) {
++					text.processNewline();
++				}
++				moveCursor(0, 0);
++				lastCursorLine = -1;
++				lastCursorColumn = -1;
++				
++			}
+ 			text.eraseAll();
+ 			break;
+ 
+@@ -858,6 +980,13 @@
+ 	private void processAnsiCommand_P() {
+ 		text.deleteCharacters(getAnsiParameter(0));
+ 	}
++	
++	/**
++	 * Set Top and Bottom Margins
++	 */
++	private void processAnsiCommand_r() {
++		text.setScrollingRegion(getAnsiParameter(0), getAnsiParameter(1));
++	}
+ 
+ 	/**
+ 	 * This method returns one of the numeric ANSI parameters received in the
+@@ -923,7 +1052,8 @@
+ 			character=getNextChar();
+ 			if(character == '\u0000' || character == '\b' || character == '\t'
+ 				|| character == '\u0007' || character == '\n'
+-				|| character == '\r' || character == '\u001b') {
++				|| character == '\r' || character == '\u001b'
++				|| character == '\u000e' || character == '\u000f') {
+ 				pushBackChar(character);
+ 				break;
+ 			}
+@@ -948,6 +1078,9 @@
+ 	 * <p>
+ 	 */
+ 	private void displayNewText(String buffer) {
++		if (insertMode) {
++			text.insertCharacters(buffer.length());
++		}
+ 		text.appendString(buffer);
+ 	}
+ 
+@@ -956,8 +1089,11 @@
+ 	 * Process a BEL (Control-G) character.
+ 	 */
+ 	private void processBEL() {
+-		// TODO
+-		//Display.getDefault().beep();
++		Display.getDefault().asyncExec(new Runnable() {
++			public void run() {
++				Display.getCurrent().beep();
++			}
++		});
+ 	}
+ 
+ 	/**
+@@ -1115,6 +1251,7 @@
+ 	public void resetState() {
+ 		ansiState=ANSISTATE_INITIAL;
+ 		text.setStyle(text.getDefaultStyle());
++		text.setCursorColumn(0);
+ 	}
+ 
+ //	public OutputStream getOutputStream() {
+Index: src/org/eclipse/tm/internal/terminal/emulator/IVT100EmulatorBackend.java
+===================================================================
+RCS file: /cvsroot/dsdp/org.eclipse.tm.core/terminal/org.eclipse.tm.terminal/src/org/eclipse/tm/internal/terminal/emulator/IVT100EmulatorBackend.java,v
+retrieving revision 1.2
+diff -u -r1.2 IVT100EmulatorBackend.java
+--- src/org/eclipse/tm/internal/terminal/emulator/IVT100EmulatorBackend.java	19 Sep 2007 02:08:10 -0000	1.2
++++ src/org/eclipse/tm/internal/terminal/emulator/IVT100EmulatorBackend.java	12 May 2010 08:15:53 -0000
+@@ -169,4 +169,11 @@
+ 
+ 	int getColumns();
+ 
++	void setScrollingRegion(int topLine, int bottomLine);
++	
++	int getScrollingRegionTopLine();
++	int getScrollingRegionBottomLine();
++	
++	void setAlternativeScreenBuffer(boolean enable);
++
+ }
+\ No newline at end of file
+Index: src/org/eclipse/tm/internal/terminal/emulator/VT100TerminalControl.java
+===================================================================
+RCS file: /cvsroot/dsdp/org.eclipse.tm.core/terminal/org.eclipse.tm.terminal/src/org/eclipse/tm/internal/terminal/emulator/VT100TerminalControl.java,v
+retrieving revision 1.27
+diff -u -r1.27 VT100TerminalControl.java
+--- src/org/eclipse/tm/internal/terminal/emulator/VT100TerminalControl.java	4 Dec 2008 19:37:11 -0000	1.27
++++ src/org/eclipse/tm/internal/terminal/emulator/VT100TerminalControl.java	12 May 2010 08:15:53 -0000
+@@ -38,6 +38,8 @@
+ import org.eclipse.core.runtime.IStatus;
+ import org.eclipse.core.runtime.Status;
+ import org.eclipse.core.runtime.jobs.Job;
++import org.eclipse.jface.bindings.keys.KeyStroke;
++import org.eclipse.jface.bindings.keys.SWTKeySupport;
+ import org.eclipse.jface.resource.JFaceResources;
+ import org.eclipse.osgi.util.NLS;
+ import org.eclipse.swt.SWT;
+@@ -67,6 +69,7 @@
+ import org.eclipse.tm.internal.terminal.provisional.api.ITerminalControl;
+ import org.eclipse.tm.internal.terminal.provisional.api.Logger;
+ import org.eclipse.tm.internal.terminal.provisional.api.TerminalState;
++import org.eclipse.tm.internal.terminal.textcanvas.ILinelRenderer;
+ import org.eclipse.tm.internal.terminal.textcanvas.ITextCanvasModel;
+ import org.eclipse.tm.internal.terminal.textcanvas.PipedInputStream;
+ import org.eclipse.tm.internal.terminal.textcanvas.PollingTextCanvasModel;
+@@ -93,6 +96,14 @@
+ public class VT100TerminalControl implements ITerminalControlForText, ITerminalControl, ITerminalViewControl
+ {
+     protected final static String[] LINE_DELIMITERS = { "\n" }; //$NON-NLS-1$
++    
++    protected final static int[] BYPASS_ACCELERATORS = new int[] {
++    	SWTKeySupport.convertKeyStrokeToAccelerator(KeyStroke.getInstance(SWT.COMMAND == SWT.MOD1 ? SWT.MOD1 : SWT.MOD1 | SWT.MOD2, 'C')),
++		SWTKeySupport.convertKeyStrokeToAccelerator(KeyStroke.getInstance(SWT.COMMAND == SWT.MOD1 ? SWT.MOD1 : SWT.MOD1 | SWT.MOD2, 'V')),
++		SWTKeySupport.convertKeyStrokeToAccelerator(KeyStroke.getInstance(SWT.COMMAND == SWT.MOD1 ? SWT.MOD1 : SWT.MOD1 | SWT.MOD2, 'A')),
++		SWTKeySupport.convertKeyStrokeToAccelerator(KeyStroke.getInstance(SWT.CONTROL, SWT.TAB)),
++		SWTKeySupport.convertKeyStrokeToAccelerator(KeyStroke.getInstance(SWT.CONTROL | SWT.SHIFT, SWT.TAB))
++    };
+ 
+     /**
+      * This field holds a reference to a TerminalText object that performs all ANSI
+@@ -119,6 +130,8 @@
+ 
+ 	private volatile TerminalState fState;
+ 
++	private boolean isApplicationKeypad = false;
++
+ 	private final ITerminalTextData fTerminalModel;
+ 
+ 	/**
+@@ -574,10 +587,8 @@
+ 		// TODO how to get the initial size correctly!
+ 		snapshot.updateSnapshot(false);
+ 		ITextCanvasModel canvasModel=new PollingTextCanvasModel(snapshot);
+-		fCtlText=new TextCanvas(fWndParent,canvasModel,SWT.NONE,new TextLineRenderer(fCtlText,canvasModel));
+-
++		fCtlText=new TextCanvas(fWndParent,canvasModel,SWT.NONE,createLineRenderer(canvasModel));
+ 
+-		fCtlText.setLayoutData(new GridData(GridData.FILL_BOTH));
+ 		fCtlText.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
+ 		fCtlText.addResizeHandler(new TextCanvas.ResizeListener() {
+ 			public void sizeChanged(int lines, int columns) {
+@@ -591,6 +602,10 @@
+ //		fViewer.setDocument(new TerminalDocument());
+ 		setFont(JFaceResources.getTextFont());
+ 	}
++	
++	protected ILinelRenderer createLineRenderer(ITextCanvasModel model) {
++		return new TextLineRenderer(null,model);
++	}
+ 
+ 	protected void setupListeners() {
+ 		fKeyHandler = new TerminalKeyHandler();
+@@ -729,6 +744,19 @@
+ 		public void keyPressed(KeyEvent event) {
+ 			if (getState()==TerminalState.CONNECTING)
+ 				return;
++			
++			int accelerator = SWTKeySupport.convertEventToUnmodifiedAccelerator(event);
++			for (int i = 0; i < BYPASS_ACCELERATORS.length; ++i) {
++				if (BYPASS_ACCELERATORS[i] == accelerator) {
++					return;
++				}
++			}
++			char character = event.character;
++			if (character == '\u0000') {
++				if ((event.stateMask & SWT.MOD1) !=0 && event.keyCode >= SWT.F1 && event.keyCode <= SWT.F15) {
++					return;
++				}
++			}
+ 
+ 			// We set the event.doit to false to prevent any further processing of this
+ 			// key event.  The only reason this is here is because I was seeing the F10
+@@ -738,8 +766,6 @@
+ 
+ 			event.doit = false;
+ 
+-			char character = event.character;
+-
+ 			//if (!isConnected()) {
+ 			if (fState==TerminalState.CLOSED) {
+ 				// Pressing ENTER while not connected causes us to connect.
+@@ -773,19 +799,19 @@
+ 
+ 				switch (event.keyCode) {
+ 				case 0x1000001: // Up arrow.
+-					sendString("\u001b[A"); //$NON-NLS-1$
++					sendString(isApplicationKeypad ? "\u001bOA" : "\u001b[A"); //$NON-NLS-1$ //$NON-NLS-2$
+ 					break;
+ 
+ 				case 0x1000002: // Down arrow.
+-					sendString("\u001b[B"); //$NON-NLS-1$
++					sendString(isApplicationKeypad ? "\u001bOB" : "\u001b[B"); //$NON-NLS-1$ //$NON-NLS-2$
+ 					break;
+ 
+ 				case 0x1000003: // Left arrow.
+-					sendString("\u001b[D"); //$NON-NLS-1$
++					sendString(isApplicationKeypad ? "\u001bOD" : "\u001b[D"); //$NON-NLS-1$ //$NON-NLS-2$
+ 					break;
+ 
+ 				case 0x1000004: // Right arrow.
+-					sendString("\u001b[C"); //$NON-NLS-1$
++					sendString(isApplicationKeypad ? "\u001bOC" : "\u001b[C"); //$NON-NLS-1$ //$NON-NLS-2$
+ 					break;
+ 
+ 				case 0x1000005: // PgUp key.
+@@ -797,11 +823,11 @@
+ 					break;
+ 
+ 				case 0x1000007: // Home key.
+-					sendString("\u001b[H"); //$NON-NLS-1$
++					sendString(isApplicationKeypad ? "\u001bOH" : "\u001b[H"); //$NON-NLS-1$ //$NON-NLS-2$
+ 					break;
+ 
+ 				case 0x1000008: // End key.
+-					sendString("\u001b[F"); //$NON-NLS-1$
++					sendString(isApplicationKeypad ? "\u001bOF" : "\u001b[F"); //$NON-NLS-1$ //$NON-NLS-2$
+ 					break;
+ 
+ 				case 0x100000a: // F1 key.
+@@ -867,6 +893,17 @@
+ 				// It's ok to return here, because we never locally echo special keys.
+ 
+ 				return;
++			} else if (event.stateMask == 0) {
++				switch (event.keyCode) {
++				case 8:
++					sendString("\u007f"); //$NON-NLS-1$
++					return;
++				case 127:
++					sendString("\u001b[3~"); //$NON-NLS-1$
++					return;
++				default:
++					break;
++				}
+ 			}
+ 
+ 			// To fix SPR 110341, we consider the Alt key to be pressed only when the
+@@ -1019,4 +1056,8 @@
+ 	public void setInvertedColors(boolean invert) {
+ 		fCtlText.setInvertedColors(invert);
+ 	}
++
++	public void setApplicationKeypad(boolean mode) {
++		isApplicationKeypad = mode;
++	}
+ }
+Index: src/org/eclipse/tm/internal/terminal/connector/TerminalConnector.java
+===================================================================
+RCS file: /cvsroot/dsdp/org.eclipse.tm.core/terminal/org.eclipse.tm.terminal/src/org/eclipse/tm/internal/terminal/connector/TerminalConnector.java,v
+retrieving revision 1.7
+diff -u -r1.7 TerminalConnector.java
+--- src/org/eclipse/tm/internal/terminal/connector/TerminalConnector.java	9 Jul 2009 10:59:44 -0000	1.7
++++ src/org/eclipse/tm/internal/terminal/connector/TerminalConnector.java	12 May 2010 08:15:53 -0000
+@@ -23,7 +23,6 @@
+ import org.eclipse.tm.internal.terminal.provisional.api.ITerminalConnector;
+ import org.eclipse.tm.internal.terminal.provisional.api.ITerminalControl;
+ import org.eclipse.tm.internal.terminal.provisional.api.Logger;
+-import org.eclipse.tm.internal.terminal.provisional.api.TerminalConnectorExtension;
+ import org.eclipse.tm.internal.terminal.provisional.api.TerminalState;
+ import org.eclipse.tm.internal.terminal.provisional.api.provider.TerminalConnectorImpl;
+ 
+@@ -44,7 +43,7 @@
+  * @noextend This class is not intended to be subclassed by clients.
+  * @noinstantiate This class is not intended to be instantiated by clients.
+  *                Clients can get terminal connector instances through the
+- *                {@link TerminalConnectorExtension} class.
++ *                {@link org.eclipse.tm.internal.terminal.provisional.api.TerminalConnectorExtension} class.
+  * @since org.eclipse.tm.terminal 2.0
+  */
+ public class TerminalConnector implements ITerminalConnector {
Index: .settings/org.eclipse.jdt.launching.prefs
===================================================================
RCS file: .settings/org.eclipse.jdt.launching.prefs
diff -N .settings/org.eclipse.jdt.launching.prefs
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ .settings/org.eclipse.jdt.launching.prefs	1 Jan 1970 00:00:00 -0000
@@ -0,0 +1,3 @@
+#Thu Apr 15 16:09:46 PDT 2010
+eclipse.preferences.version=1
+org.eclipse.jdt.launching.PREF_STRICTLY_COMPATIBLE_JRE_NOT_AVAILABLE=ignore
